Sha256: 9d1afb7356aae4f83a1329d2722035b267407952ecb8ccb59d99069ee468a788

Contents?: true

Size: 808 Bytes

Versions: 6

Compression:

Stored size: 808 Bytes

Contents

module TableGo
  class Column
    attr_accessor :table, :name, :options, :block

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

    def label
      options[:label]
    end

    def as
      options[:as]
    end

    def send
      options[:send]
    end

    def as_options
      options[:as_options] || {}
    end

    def header_html
      options[:header_html]
    end

    def column_html
      options[:column_html]
    end

    def method
      options[:method]
    end

    def human_attribute_name
      if table.model_klass.respond_to?(:human_attribute_name) # using rails default I18n
        table.model_klass.human_attribute_name(name).html_safe
      else
        name.to_s.humanize
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
table_go-0.2.6 lib/table_go/column.rb
table_go-0.2.5 lib/table_go/column.rb
table_go-0.2.4 lib/table_go/column.rb
table_go-0.2.3 lib/table_go/column.rb
table_go-0.2.2 lib/table_go/column.rb
table_go-0.2.1 lib/table_go/column.rb