Sha256: 76cf0d3a99de60e5f523bf7677aeaa9eb656d95d8495180a70167206072365e9
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module TableGo class Table attr_accessor :collection, :model_klass attr_accessor :columns def initialize(collection, model_klass, options, &block) @collection = collection @model_klass = model_klass @columns = [] apply_options!(options) evaluate_dsl!(block) end def evaluate_dsl!(block) if block # instance_eval(&block) block.call(self) else attribute_names_from_model_klass.each do |column_name| column(column_name) end end end # def model_klass_reflection_keys # @model_klass_reflection_keys ||= model_klass.reflections.keys # end def attribute_names_from_model_klass model_klass.respond_to?(:column_names) ? model_klass.column_names : [] end def apply_options!(options) options.each { |k, v| send(k, v) } end def column(name, options = {}, &block) @columns << Column.new(self, name, options, &block) end def title(title = nil) @title = title if title @title end def table_html(table_html = nil) @table_html = table_html if table_html @table_html end def row_html(row_html = nil) @row_html = row_html if row_html @row_html end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_go-0.2.3 | lib/table_go/table.rb |