Class: Magentwo::Filter::Compare
- Inherits:
-
Object
- Object
- Magentwo::Filter::Compare
- Defined in:
- lib/filter.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(field, value) ⇒ Compare
constructor
A new instance of Compare.
- #to_query(idx, field: self.field, value: self.value) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(field, value) ⇒ Compare
Returns a new instance of Compare.
5 6 7 8 |
# File 'lib/filter.rb', line 5 def initialize field, value @field = field @value = value end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
4 5 6 |
# File 'lib/filter.rb', line 4 def field @field end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/filter.rb', line 4 def value @value end |
Instance Method Details
#to_query(idx, field: self.field, value: self.value) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/filter.rb', line 10 def to_query idx, field:self.field, value:self.value [ "searchCriteria[filter_groups][#{idx}][filters][0][field]=#{self.field}", "searchCriteria[filter_groups][#{idx}][filters][0][value]=#{CGI.escape(self.value.to_s)}", "searchCriteria[filter_groups][#{idx}][filters][0][condition_type]=#{self.class.name.split("::").last.downcase}"] .join("&") end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/filter.rb', line 18 def to_s "#{self.field} #{self.class.name.split("::").last.downcase} #{self.value}" end |