Class: Refinuri::Base::FilterSet
- Inherits:
-
Object
- Object
- Refinuri::Base::FilterSet
- Defined in:
- lib/refinuri/base.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #[](filter_name) ⇒ Object
-
#initialize(hash) ⇒ FilterSet
constructor
A new instance of FilterSet.
- #merge!(hash) ⇒ Object
- #to_h ⇒ Object
- #to_url ⇒ Object
Constructor Details
#initialize(hash) ⇒ FilterSet
Returns a new instance of FilterSet.
5 6 7 8 9 |
# File 'lib/refinuri/base.rb', line 5 def initialize(hash) raise ArgumentError, "Argument must be a Hash", caller unless hash.is_a?(Hash) @filters = Hash.new modify_filters(hash) end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
4 5 6 |
# File 'lib/refinuri/base.rb', line 4 def filters @filters end |
Instance Method Details
#[](filter_name) ⇒ Object
18 19 20 |
# File 'lib/refinuri/base.rb', line 18 def [](filter_name) @filters[filter_name]# && @filters[filter_name].value end |
#merge!(hash) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/refinuri/base.rb', line 11 def merge!(hash) hash[:update] ||= Hash.new hash[:update].merge!(extract_implicit_filters(hash)) hash.each { |key,value| modify_filters(value,key) } return self end |
#to_h ⇒ Object
22 23 24 25 26 |
# File 'lib/refinuri/base.rb', line 22 def to_h filters = Hash.new @filters.each { |key,value| filters[key] = value.value } return filters end |