Sha256: 2e463132e6ab7f253b31f517c4a2f59d21aae1d925ec3a01e7c9bfebc62b0cd6

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

module TableCloth
  class Column
    attr_reader :options, :name

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

    def value(object, view, table=nil)
      if options[:proc] && options[:proc].respond_to?(:call)
        view.capture(object, options, view, &options[:proc])
      else
        object.send(name)
      end
    end

    def human_name
      options[:label] || name.to_s.humanize
    end

    def available?(table)
      if options[:if] && options[:if].is_a?(Symbol)
        return !!table.send(options[:if])
      end

      if options[:unless] && options[:unless].is_a?(Symbol)
        return !table.send(options[:unless])
      end

      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_cloth-0.1.1 lib/table_cloth/column.rb