Class: ActiveAdmin::CSVBuilder::Column
- Inherits:
-
Object
- Object
- ActiveAdmin::CSVBuilder::Column
- Defined in:
- lib/active_admin/csv_builder.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ humanize_name: true }
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #humanize_name(name, resource, humanize_name_option) ⇒ Object
-
#initialize(name, resource = nil, options = {}, block = nil) ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(name, resource = nil, options = {}, block = nil) ⇒ Column
Returns a new instance of Column.
102 103 104 105 106 |
# File 'lib/active_admin/csv_builder.rb', line 102 def initialize(name, resource = nil, = {}, block = nil) @options = .reverse_merge(DEFAULT_OPTIONS) @name = humanize_name(name, resource, @options[:humanize_name]) @data = block || name.to_sym end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
98 99 100 |
# File 'lib/active_admin/csv_builder.rb', line 98 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
98 99 100 |
# File 'lib/active_admin/csv_builder.rb', line 98 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
98 99 100 |
# File 'lib/active_admin/csv_builder.rb', line 98 def @options end |
Instance Method Details
#humanize_name(name, resource, humanize_name_option) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/active_admin/csv_builder.rb', line 108 def humanize_name(name, resource, humanize_name_option) if humanize_name_option name.is_a?(Symbol) && resource ? resource.resource_class.human_attribute_name(name) : name.to_s.humanize else name.to_s end end |