aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/core_extensions/object.rb
blob: 82fa28546c0fc0cdc2f5ee9ca7928b80bae5adc0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Arel
  module ObjectExtensions
    def bind(relation)
      Arel::Value.new(self, relation)
    end

    def find_correlate_in(relation)
      bind(relation)
    end

    def let
      yield(self)
    end

    # TODO remove this when ActiveSupport beta1 is out.
    # Returns the object's singleton class.
    def singleton_class
      class << self
        self
      end
    end unless respond_to?(:singleton_class)

    # class_eval on an object acts like singleton_class_eval.
    def class_eval(*args, &block)
      singleton_class.class_eval(*args, &block)
    end

    Object.send(:include, self)
  end
end