Class: Tableize::ColumnBuilder
- Inherits:
-
Object
- Object
- Tableize::ColumnBuilder
- Defined in:
- lib/tableize/column_builder.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(resource_class, *args, &block) ⇒ ColumnBuilder
constructor
A new instance of ColumnBuilder.
- #td_options ⇒ Object
- #th_options ⇒ Object
- #value(resource, extras) ⇒ Object
Constructor Details
#initialize(resource_class, *args, &block) ⇒ ColumnBuilder
Returns a new instance of ColumnBuilder.
6 7 8 9 10 11 12 13 |
# File 'lib/tableize/column_builder.rb', line 6 def initialize(resource_class, *args, &block) @options = args. @resource_class = resource_class @html_options = @options.delete(:html) || {} @block = block @title = get_title(args) @method = get_method(args) end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
4 5 6 |
# File 'lib/tableize/column_builder.rb', line 4 def method @method end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/tableize/column_builder.rb', line 4 def title @title end |
Instance Method Details
#td_options ⇒ Object
29 30 31 |
# File 'lib/tableize/column_builder.rb', line 29 def (:td) end |
#th_options ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/tableize/column_builder.rb', line 33 def = (:th) if @method [:class] = Tableize::convert_to_array([:class], @method.to_s.underscore, value_type) end end |
#value(resource, extras) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tableize/column_builder.rb', line 15 def value(resource, extras) if @block @method ? @block.call(resource.send(@method), *extras) : @block.call(resource, *extras) else if @method if resource.respond_to?(@method) resource.send(@method) elsif resource.kind_of?(Hash) resource[@method] end end end end |