Class: Ardm::Query::Expression
- Inherits:
-
Object
- Object
- Ardm::Query::Expression
- Defined in:
- lib/ardm/query/expression.rb
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #arel_target ⇒ Object
-
#initialize(relation, target, operator, value) ⇒ Expression
constructor
A new instance of Expression.
- #resolved_target ⇒ Object
- #scope ⇒ Object
- #to_arel ⇒ Object
Constructor Details
#initialize(relation, target, operator, value) ⇒ Expression
Returns a new instance of Expression.
10 11 12 13 14 15 |
# File 'lib/ardm/query/expression.rb', line 10 def initialize(relation, target, operator, value) @relation = relation @value = value @target = target @operator = operator end |
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
4 5 6 |
# File 'lib/ardm/query/expression.rb', line 4 def operator @operator end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
4 5 6 |
# File 'lib/ardm/query/expression.rb', line 4 def relation @relation end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/ardm/query/expression.rb', line 4 def target @target end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/ardm/query/expression.rb', line 4 def value @value end |
Class Method Details
.build_scope(relation, target, value) ⇒ Object
6 7 8 |
# File 'lib/ardm/query/expression.rb', line 6 def self.build_scope(relation, target, value) new(relation, target, value).scope end |
Instance Method Details
#arel_target ⇒ Object
21 22 23 |
# File 'lib/ardm/query/expression.rb', line 21 def arel_target arel_table[resolved_target] end |
#resolved_target ⇒ Object
17 18 19 |
# File 'lib/ardm/query/expression.rb', line 17 def resolved_target target_from_association || target end |
#scope ⇒ Object
29 30 31 |
# File 'lib/ardm/query/expression.rb', line 29 def scope relation.where to_arel end |
#to_arel ⇒ Object
25 26 27 |
# File 'lib/ardm/query/expression.rb', line 25 def to_arel arel_target.send(arel_operator, arel_value) end |