Class: Livelist::Rails::FilterCriterion
- Inherits:
-
Object
- Object
- Livelist::Rails::FilterCriterion
- Defined in:
- lib/livelist/rails/filter_criterion.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #as_json(params) ⇒ Object
-
#initialize(options = {}) ⇒ FilterCriterion
constructor
A new instance of FilterCriterion.
- #selected?(params) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ FilterCriterion
Returns a new instance of FilterCriterion.
14 15 16 17 18 19 20 21 22 |
# File 'lib/livelist/rails/filter_criterion.rb', line 14 def initialize( = {}) @filter = [:filter] @criteria = [:criteria] @reference = [:reference] @type = infer_type @label = @filter.criterion_label || infer_label @slug = infer_slug @name = infer_name end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
7 8 9 |
# File 'lib/livelist/rails/filter_criterion.rb', line 7 def count @count end |
#label ⇒ Object
Returns the value of attribute label.
7 8 9 |
# File 'lib/livelist/rails/filter_criterion.rb', line 7 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/livelist/rails/filter_criterion.rb', line 7 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug.
7 8 9 |
# File 'lib/livelist/rails/filter_criterion.rb', line 7 def slug @slug end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/livelist/rails/filter_criterion.rb', line 7 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/livelist/rails/filter_criterion.rb', line 7 def value @value end |
Instance Method Details
#as_json(params) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/livelist/rails/filter_criterion.rb', line 28 def as_json(params) .merge( :slug => @filter.slug, :name => @name, :value => @slug.to_s, :count => @count, :selected => selected?(params) ) end |
#selected?(params) ⇒ Boolean
24 25 26 |
# File 'lib/livelist/rails/filter_criterion.rb', line 24 def selected?(params) params.nil? ? false : params.include?(slug.to_s) end |