Class: Squeel::Nodes::Stub

Inherits:
Object
  • Object
show all
Includes:
Operators, PredicateMethods
Defined in:
lib/squeel/nodes/stub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Operators

#*, #+, #-, #/, #op

Methods included from PredicateMethods

included

Constructor Details

#initialize(symbol) ⇒ Stub

Returns a new instance of Stub.



13
14
15
# File 'lib/squeel/nodes/stub.rb', line 13

def initialize(symbol)
  @symbol = symbol
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/squeel/nodes/stub.rb', line 34

def method_missing(method_id, *args)
  super if method_id == :to_ary
  if (args.size == 1) && (Class === args[0])
    KeyPath.new(self, Join.new(method_id, Arel::InnerJoin, args[0]))
  else
    KeyPath.new(self, method_id)
  end
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol.



11
12
13
# File 'lib/squeel/nodes/stub.rb', line 11

def symbol
  @symbol
end

Instance Method Details

#<(value) ⇒ Object



81
82
83
# File 'lib/squeel/nodes/stub.rb', line 81

def <(value)
  Predicate.new self.symbol, :lt, value
end

#<<(value) ⇒ Object



60
61
62
# File 'lib/squeel/nodes/stub.rb', line 60

def <<(value)
  Predicate.new self.symbol, :not_in, value
end

#<=(value) ⇒ Object



85
86
87
# File 'lib/squeel/nodes/stub.rb', line 85

def <=(value)
  Predicate.new self.symbol, :lteq, value
end

#==(value) ⇒ Object



43
44
45
# File 'lib/squeel/nodes/stub.rb', line 43

def ==(value)
  Predicate.new self.symbol, :eq, value
end

#=~(value) ⇒ Object



64
65
66
# File 'lib/squeel/nodes/stub.rb', line 64

def =~(value)
  Predicate.new self.symbol, :matches, value
end

#>(value) ⇒ Object



73
74
75
# File 'lib/squeel/nodes/stub.rb', line 73

def >(value)
  Predicate.new self.symbol, :gt, value
end

#>=(value) ⇒ Object



77
78
79
# File 'lib/squeel/nodes/stub.rb', line 77

def >=(value)
  Predicate.new self.symbol, :gteq, value
end

#>>(value) ⇒ Object



56
57
58
# File 'lib/squeel/nodes/stub.rb', line 56

def >>(value)
  Predicate.new self.symbol, :in, value
end

#^(value) ⇒ Object



52
53
54
# File 'lib/squeel/nodes/stub.rb', line 52

def ^(value)
  Predicate.new self.symbol, :not_eq, value
end

#ascObject



89
90
91
# File 'lib/squeel/nodes/stub.rb', line 89

def asc
  Order.new self.symbol, 1
end

#descObject



93
94
95
# File 'lib/squeel/nodes/stub.rb', line 93

def desc
  Order.new self.symbol, -1
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/squeel/nodes/stub.rb', line 17

def eql?(other)
  self.class == other.class &&
  self.symbol == other.symbol
end

#func(*args) ⇒ Object Also known as: []



97
98
99
# File 'lib/squeel/nodes/stub.rb', line 97

def func(*args)
  Function.new(self.symbol, args)
end

#hashObject



22
23
24
# File 'lib/squeel/nodes/stub.rb', line 22

def hash
  symbol.hash
end

#innerObject



103
104
105
# File 'lib/squeel/nodes/stub.rb', line 103

def inner
  Join.new(self.symbol, Arel::InnerJoin)
end

#of_class(klass) ⇒ Object



111
112
113
# File 'lib/squeel/nodes/stub.rb', line 111

def of_class(klass)
  Join.new(self.symbol, Arel::InnerJoin, klass)
end

#outerObject



107
108
109
# File 'lib/squeel/nodes/stub.rb', line 107

def outer
  Join.new(self.symbol, Arel::OuterJoin)
end

#to_sObject



30
31
32
# File 'lib/squeel/nodes/stub.rb', line 30

def to_s
  symbol.to_s
end

#to_symObject



26
27
28
# File 'lib/squeel/nodes/stub.rb', line 26

def to_sym
  symbol
end