Class: EasyTable::Base
- Inherits:
-
Object
- Object
- EasyTable::Base
- Defined in:
- lib/easy_table/base.rb
Defined Under Namespace
Classes: NilModelClass
Instance Attribute Summary collapse
-
#action_columns ⇒ Object
readonly
Returns the value of attribute action_columns.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#presenter ⇒ Object
Returns the value of attribute presenter.
Instance Method Summary collapse
- #action(&block) ⇒ Object
- #all_columns ⇒ Object
-
#initialize(items, options = {}) ⇒ Base
constructor
options: model_class: the class of the model, used for i18n, using with the human_attribute_name.
- #process_options ⇒ Object
- #td(name, options = {}, &block) ⇒ Object
- #tds(*names) ⇒ Object
Constructor Details
#initialize(items, options = {}) ⇒ Base
options:
model_class: the class of the model, used for i18n, using with the human_attribute_name
10 11 12 13 14 15 16 |
# File 'lib/easy_table/base.rb', line 10 def initialize(items, = {}) @items = items @options = @columns = [] @action_columns = [] end |
Instance Attribute Details
#action_columns ⇒ Object (readonly)
Returns the value of attribute action_columns.
3 4 5 |
# File 'lib/easy_table/base.rb', line 3 def action_columns @action_columns end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
3 4 5 |
# File 'lib/easy_table/base.rb', line 3 def columns @columns end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
3 4 5 |
# File 'lib/easy_table/base.rb', line 3 def items @items end |
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
3 4 5 |
# File 'lib/easy_table/base.rb', line 3 def model_class @model_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/easy_table/base.rb', line 3 def @options end |
#presenter ⇒ Object
Returns the value of attribute presenter.
4 5 6 |
# File 'lib/easy_table/base.rb', line 4 def presenter @presenter end |
Instance Method Details
#action(&block) ⇒ Object
26 27 28 |
# File 'lib/easy_table/base.rb', line 26 def action(&block) @action_columns << ActionColumn.new("", {}, &block) end |
#all_columns ⇒ Object
30 31 32 |
# File 'lib/easy_table/base.rb', line 30 def all_columns @all_columns ||= (columns + action_columns) end |
#process_options ⇒ Object
34 35 36 |
# File 'lib/easy_table/base.rb', line 34 def @model_class = [:model_class] || NilModelClass.instance end |
#td(name, options = {}, &block) ⇒ Object
22 23 24 |
# File 'lib/easy_table/base.rb', line 22 def td(name, = {}, &block) @columns << Column.new(name, , &block) end |
#tds(*names) ⇒ Object
18 19 20 |
# File 'lib/easy_table/base.rb', line 18 def tds(*names) names.each { |name| td(name) } end |