Class: Outpost::List::Filter
- Inherits:
-
Object
- Object
- Outpost::List::Filter
- Defined in:
- lib/outpost/list/filter.rb
Constant Summary collapse
- BOOLEAN_COLLECT =
[["Yes", 1], ["No", 0]]
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#list ⇒ Object
Returns the value of attribute list.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(attribute, list, options = {}) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(attribute, list, options = {}) ⇒ Filter
Returns a new instance of Filter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/outpost/list/filter.rb', line 11 def initialize(attribute, list, ={}) @attribute = attribute.to_s @list = list @title = [:title] || @attribute.titleize collection = [:collection] @collection = begin case collection when NilClass # No collection given. Find it ourselves. if list.model.column_names.include?(@attribute) -> { list.model.order(@attribute).pluck("distinct #{@attribute}") } else # TODO Handle association filtering end when Proc collection when Symbol send "_#{collection}_collection" end end end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
9 10 11 |
# File 'lib/outpost/list/filter.rb', line 9 def attribute @attribute end |
#collection ⇒ Object
Returns the value of attribute collection.
9 10 11 |
# File 'lib/outpost/list/filter.rb', line 9 def collection @collection end |
#list ⇒ Object
Returns the value of attribute list.
9 10 11 |
# File 'lib/outpost/list/filter.rb', line 9 def list @list end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/outpost/list/filter.rb', line 9 def title @title end |