Class: Grape::Entity::Condition::HashCondition
- Inherits:
-
Base
- Object
- Base
- Grape::Entity::Condition::HashCondition
show all
- Defined in:
- lib/grape_entity/condition/hash_condition.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #inversed?, #met?, new
Instance Attribute Details
#cond_hash ⇒ Object
Returns the value of attribute cond_hash.
5
6
7
|
# File 'lib/grape_entity/condition/hash_condition.rb', line 5
def cond_hash
@cond_hash
end
|
Instance Method Details
#==(other) ⇒ Object
11
12
13
|
# File 'lib/grape_entity/condition/hash_condition.rb', line 11
def ==(other)
super && @cond_hash == other.cond_hash
end
|
#if_value(_entity, options) ⇒ Object
15
16
17
|
# File 'lib/grape_entity/condition/hash_condition.rb', line 15
def if_value(_entity, options)
@cond_hash.all? { |k, v| options[k.to_sym] == v }
end
|
#setup(cond_hash) ⇒ Object
7
8
9
|
# File 'lib/grape_entity/condition/hash_condition.rb', line 7
def setup(cond_hash)
@cond_hash = cond_hash
end
|
#unless_value(_entity, options) ⇒ Object
19
20
21
|
# File 'lib/grape_entity/condition/hash_condition.rb', line 19
def unless_value(_entity, options)
@cond_hash.any? { |k, v| options[k.to_sym] != v }
end
|