Class: GrubY::Filters::EntityFilter
- Defined in:
- lib/gruubY/filters.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from Filter
Instance Method Summary collapse
- #add(value) ⇒ Object
- #clear ⇒ Object
- #delete(value) ⇒ Object
-
#initialize(name, values = nil, &matcher) ⇒ EntityFilter
constructor
A new instance of EntityFilter.
Methods inherited from Filter
Constructor Details
#initialize(name, values = nil, &matcher) ⇒ EntityFilter
Returns a new instance of EntityFilter.
33 34 35 36 37 38 39 |
# File 'lib/gruubY/filters.rb', line 33 def initialize(name, values = nil, &matcher) @values = normalize(values) @matcher = matcher super(name) do |_filter, _client, update| @matcher.call(update, @values) end end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
31 32 33 |
# File 'lib/gruubY/filters.rb', line 31 def values @values end |
Instance Method Details
#add(value) ⇒ Object
41 42 43 44 |
# File 'lib/gruubY/filters.rb', line 41 def add(value) @values.merge(normalize(value)) self end |
#clear ⇒ Object
51 52 53 54 |
# File 'lib/gruubY/filters.rb', line 51 def clear @values.clear self end |
#delete(value) ⇒ Object
46 47 48 49 |
# File 'lib/gruubY/filters.rb', line 46 def delete(value) normalize(value).each { |v| @values.delete(v) } self end |