Class: Aerogel::Admin::TableBuilder::Column
- Inherits:
-
Object
- Object
- Aerogel::Admin::TableBuilder::Column
- Defined in:
- lib/aerogel/admin/table_builder.rb
Constant Summary collapse
- KNOWN_OPTIONS =
[ :label ]
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#field ⇒ Object
Returns the value of attribute field.
-
#label ⇒ Object
Returns the value of attribute label.
-
#options ⇒ Object
Returns the value of attribute options.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
-
#html_params ⇒ Object
Renders html params for column cells.
- #human_label ⇒ Object
-
#initialize(table, field, options = {}, &block) ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(table, field, options = {}, &block) ⇒ Column
Returns a new instance of Column.
62 63 64 65 66 67 68 |
# File 'lib/aerogel/admin/table_builder.rb', line 62 def initialize( table, field, = {}, &block ) self.table = table self.field = field self. = self.block = block self.label = self.[:label] || self.field.to_sym end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
58 59 60 |
# File 'lib/aerogel/admin/table_builder.rb', line 58 def block @block end |
#field ⇒ Object
Returns the value of attribute field.
58 59 60 |
# File 'lib/aerogel/admin/table_builder.rb', line 58 def field @field end |
#label ⇒ Object
Returns the value of attribute label.
58 59 60 |
# File 'lib/aerogel/admin/table_builder.rb', line 58 def label @label end |
#options ⇒ Object
Returns the value of attribute options.
58 59 60 |
# File 'lib/aerogel/admin/table_builder.rb', line 58 def @options end |
#table ⇒ Object
Returns the value of attribute table.
58 59 60 |
# File 'lib/aerogel/admin/table_builder.rb', line 58 def table @table end |
Instance Method Details
#html_params ⇒ Object
Renders html params for column cells
88 89 90 91 92 |
# File 'lib/aerogel/admin/table_builder.rb', line 88 def html_params attrs = @options.except( *KNOWN_OPTIONS ) attrs = attrs.deep_merge( @options[:html_params] ) if @options.key? :html_params attrs.to_html_params end |
#human_label ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/aerogel/admin/table_builder.rb', line 70 def human_label if label.is_a? Symbol if table.object.respond_to? :human_attribute_name table.object.human_attribute_name label, default: label elsif table.object.respond_to?( :first ) && table.object.first.class.respond_to?( :human_attribute_name ) table.object.first.class.human_attribute_name label, default: label else I18n.t label end elsif label.is_a? String label else label.to_s.humanize end end |