Class: Activecube::Query::Selector
- Inherits:
-
Item
- Object
- Item
- Activecube::Query::Selector
show all
- Defined in:
- lib/activecube/query/selector.rb
Defined Under Namespace
Classes: CombineSelector, Operator
Constant Summary
collapse
- OPERATORS =
['eq','not_eq','gt','lt','gteq','lteq','in','not_in','between']
- ARRAY_OPERATORS =
['in','not_in']
- ARRAY_OPERATOR_MAP =
{
'eq' => 'in',
'not_eq' => 'not_in'
}
Instance Attribute Summary collapse
Attributes inherited from Item
#cube, #definition, #key
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Item
#required_column_names
Constructor Details
#initialize(cube, key, definition, operator = nil) ⇒ Selector
Returns a new instance of Selector.
75
76
77
78
|
# File 'lib/activecube/query/selector.rb', line 75
def initialize cube, key, definition, operator = nil
super cube, key, definition
@operator = operator
end
|
Instance Attribute Details
#operator ⇒ Object
Returns the value of attribute operator.
74
75
76
|
# File 'lib/activecube/query/selector.rb', line 74
def operator
@operator
end
|
Class Method Details
.and(selectors) ⇒ Object
143
144
145
|
# File 'lib/activecube/query/selector.rb', line 143
def self.and(selectors)
CombineSelector.new(selectors, Operator.new(:and, nil))
end
|
.or(selectors) ⇒ Object
139
140
141
|
# File 'lib/activecube/query/selector.rb', line 139
def self.or(selectors)
CombineSelector.new(selectors, Operator.new(:or, nil) )
end
|
Instance Method Details
#==(other) ⇒ Object
127
128
129
|
# File 'lib/activecube/query/selector.rb', line 127
def == other
eql? other
end
|
#alias!(new_key) ⇒ Object
108
109
110
|
# File 'lib/activecube/query/selector.rb', line 108
def alias! new_key
self.class.new cube, new_key, definition, operator
end
|
#append_query(model, cube_query, table, query) ⇒ Object
112
113
114
|
# File 'lib/activecube/query/selector.rb', line 112
def append_query model, cube_query, table, query
query.where(expression model, table, cube_query)
end
|
#eql?(other) ⇒ Boolean
120
121
122
123
124
125
|
# File 'lib/activecube/query/selector.rb', line 120
def eql?(other)
return other.kind_of?(Selector) &&
self.cube==other.cube &&
self.operator == other.operator &&
self.definition.class == other.definition.class
end
|
#expression(model, arel_table, cube_query) ⇒ Object
116
117
118
|
# File 'lib/activecube/query/selector.rb', line 116
def expression model, arel_table, cube_query
definition.expression model, arel_table, self, cube_query
end
|
#hash ⇒ Object
131
132
133
|
# File 'lib/activecube/query/selector.rb', line 131
def hash
self.definition.class.hash + self.operator.hash
end
|
#to_s ⇒ Object
135
136
137
|
# File 'lib/activecube/query/selector.rb', line 135
def to_s
"Selector #{super}"
end
|