Class: Everdeen::Criterion
- Inherits:
-
Object
- Object
- Everdeen::Criterion
- Defined in:
- lib/everdeen/criterion.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Criterion
constructor
A new instance of Criterion.
- #match_type ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Criterion
Returns a new instance of Criterion.
5 6 7 8 9 |
# File 'lib/everdeen/criterion.rb', line 5 def initialize(args = {}) args.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/everdeen/criterion.rb', line 3 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/everdeen/criterion.rb', line 3 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/everdeen/criterion.rb', line 3 def value @value end |
Instance Method Details
#match_type ⇒ Object
11 12 13 |
# File 'lib/everdeen/criterion.rb', line 11 def match_type @match_type || 'exact' end |
#to_hash ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/everdeen/criterion.rb', line 15 def to_hash base = { key: key, match_type: match_type, type: type } if query_param_type? && value.is_a?(Array) base.merge(values: value) else base.merge(value: value) end end |