Class: ActiveRecord::Query::Subject

Inherits:
BasicObject
Defined in:
lib/active_record/query/subject.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, name, table = nil) ⇒ Subject

Returns a new instance of Subject.



3
4
5
6
7
# File 'lib/active_record/query/subject.rb', line 3

def initialize(owner, name, table = nil)
  @owner = owner
  @name  = name
  @table = table || @owner.table
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/active_record/query/subject.rb', line 9

def method_missing(method_name, *args, &block)
  if args.empty? && !block
    Subject.new(@owner, method_name, ::Arel::Table.new(@name))
  else
    ::Kernel.raise ::ArgumentError
  end
end

Instance Method Details

#!=(value) ⇒ Object



25
26
27
# File 'lib/active_record/query/subject.rb', line 25

def !=(value)
  __add__ :not_eq, value
end

#!~(value) ⇒ Object



33
34
35
# File 'lib/active_record/query/subject.rb', line 33

def !~(value)
  __add__ :does_not_match, value
end

#<(value) ⇒ Object



41
42
43
# File 'lib/active_record/query/subject.rb', line 41

def <(value)
  __add__ :lt, value
end

#<=(value) ⇒ Object



49
50
51
# File 'lib/active_record/query/subject.rb', line 49

def <=(value)
  __add__ :lteq, value
end

#==(value) ⇒ Object



21
22
23
# File 'lib/active_record/query/subject.rb', line 21

def ==(value)
  __add__ :eq, value
end

#=~(value) ⇒ Object



29
30
31
# File 'lib/active_record/query/subject.rb', line 29

def =~(value)
  __add__ :matches, value
end

#>(value) ⇒ Object



37
38
39
# File 'lib/active_record/query/subject.rb', line 37

def >(value)
  __add__ :gt, value
end

#>=(value) ⇒ Object



45
46
47
# File 'lib/active_record/query/subject.rb', line 45

def >=(value)
  __add__ :gteq, value
end

#in(value) ⇒ Object



53
54
55
# File 'lib/active_record/query/subject.rb', line 53

def in(value)
  __add__ :in, value
end

#not_in(value) ⇒ Object



57
58
59
# File 'lib/active_record/query/subject.rb', line 57

def not_in(value)
  __add__ :not_in, value
end

#respond_to?(name, include_private = nil) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/active_record/query/subject.rb', line 17

def respond_to?(name, include_private = nil)
  true
end