Class: YADM::Criteria
- Inherits:
-
Object
- Object
- YADM::Criteria
- Defined in:
- lib/yadm/criteria.rb,
lib/yadm/criteria/limit.rb,
lib/yadm/criteria/order.rb,
lib/yadm/criteria/argument.rb,
lib/yadm/criteria/attribute.rb,
lib/yadm/criteria/condition.rb,
lib/yadm/criteria/expression.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Argument, Attribute, Condition, Expression, Limit, Order
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(condition: nil, order: nil, limit: nil) ⇒ Criteria
constructor
A new instance of Criteria.
- #merge(other_criteria) ⇒ Object
Constructor Details
#initialize(condition: nil, order: nil, limit: nil) ⇒ Criteria
Returns a new instance of Criteria.
12 13 14 15 16 |
# File 'lib/yadm/criteria.rb', line 12 def initialize(condition: nil, order: nil, limit: nil) @condition = condition @order = order @limit = limit end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
10 11 12 |
# File 'lib/yadm/criteria.rb', line 10 def condition @condition end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
10 11 12 |
# File 'lib/yadm/criteria.rb', line 10 def limit @limit end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
10 11 12 |
# File 'lib/yadm/criteria.rb', line 10 def order @order end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 |
# File 'lib/yadm/criteria.rb', line 26 def ==(other) %i(condition order limit).all? do |method| other.respond_to?(method) && send(method) == other.send(method) end end |
#merge(other_criteria) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/yadm/criteria.rb', line 18 def merge(other_criteria) self.class.new( condition: Condition.merge(condition, other_criteria.condition), order: Order.merge(order, other_criteria.order), limit: Limit.merge(limit, other_criteria.limit) ) end |