Sha256: f32a521a0ceeafdb102384757a61ee81116c2108234ed7ccc7a411080683cee4

Contents?: true

Size: 555 Bytes

Versions: 4

Compression:

Stored size: 555 Bytes

Contents

module Tableficate
  class Filter
    attr_reader :name, :label, :options, :template, :table, :field_name

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tableficate-0.1.3 lib/tableficate/filters/filter.rb
tableficate-0.1.2 lib/tableficate/filters/filter.rb
tableficate-0.1.1 lib/tableficate/filters/filter.rb
tableficate-0.0.1 lib/tableficate/filters/filter.rb