Class: Tableficate::Filter::Base
- Inherits:
-
Object
- Object
- Tableficate::Filter::Base
- Defined in:
- lib/tableficate/filters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#label_options ⇒ Object
readonly
Returns the value of attribute label_options.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #field_value(params) ⇒ Object
-
#initialize(table, name, options = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(table, name, options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/tableficate/filters/base.rb', line 6 def initialize(table, name, = {}) @table = table @name = name @label = .delete(:label) || table.columns.detect{|column| column.name == @name}.try(:header) || name.to_s.titleize = .delete(:label_options) || {} @attrs = @template = 'filters/' + self.class.name.demodulize.underscore @field_name = "#{table.as}[filter][#{@name}]" end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def attrs @attrs end |
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def field_name @field_name end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def label @label end |
#label_options ⇒ Object (readonly)
Returns the value of attribute label_options.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def name @name end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def table @table end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
4 5 6 |
# File 'lib/tableficate/filters/base.rb', line 4 def template @template end |
Instance Method Details
#field_value(params) ⇒ Object
18 19 20 |
# File 'lib/tableficate/filters/base.rb', line 18 def field_value(params) params[:filter][@name] rescue '' end |