Class: Tableficate::Filter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/tableficate/filters/base.rb

Direct Known Subclasses

CheckBox, Input, InputRange, Radio, Select, SelectRange

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, name, options = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
13
14
# File 'lib/tableficate/filters/base.rb', line 6

def initialize(table, name, options = {})
  @table   = table
  @name    = name
  @options = options

  @template   = 'filters/' + self.class.name.demodulize.underscore
  @label      = @options.delete(:label) || table.columns.detect{|column| column.name == @name}.try(:header) || name.to_s.titleize
  @field_name = "#{table.as}[filter][#{@name}]"
end

Instance Attribute Details

#field_nameObject (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

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/tableficate/filters/base.rb', line 4

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/tableficate/filters/base.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/tableficate/filters/base.rb', line 4

def options
  @options
end

#tableObject (readonly)

Returns the value of attribute table.



4
5
6
# File 'lib/tableficate/filters/base.rb', line 4

def table
  @table
end

#templateObject (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



16
17
18
# File 'lib/tableficate/filters/base.rb', line 16

def field_value(params)
  params[:filter][@name] rescue ''
end