Module: Csvbuilder::AttributesBase
- Extended by:
- ActiveSupport::Concern
- Includes:
- Model::Attributes, Proxy
- Defined in:
- lib/csvbuilder/core/concerns/attributes_base.rb
Constant Summary collapse
- ATTRIBUTE_METHODS =
Import: source_value - form source_row formatted_value - format_cell(source_value) value - calculated_value from a bunch of stuff
{ original_attributes: :value, # a map of `column_name => original_attribute(column_name)` formatted_attributes: :formatted_value, # a map of `column_name => format_cell(column_name, ...)` source_attributes: :source_value # a map of `column_name => source (source_row[index_of_column_name] or row_model.public_send(column_name)) ` }.freeze
Instance Method Summary collapse
-
#attributes ⇒ Hash
A map of ‘column_name => public_send(column_name)`.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#original_attribute(column_name) ⇒ Object
The column’s attribute.
- #to_json(*_args) ⇒ Object
Methods included from Model::Attributes
Instance Method Details
#attributes ⇒ Hash
Returns a map of ‘column_name => public_send(column_name)`.
13 14 15 |
# File 'lib/csvbuilder/core/concerns/attributes_base.rb', line 13 def attributes attributes_from_method_names self.class.column_names end |
#eql?(other) ⇒ Boolean
41 42 43 |
# File 'lib/csvbuilder/core/concerns/attributes_base.rb', line 41 def eql?(other) other.try(:attributes) == attributes end |
#hash ⇒ Object
45 46 47 |
# File 'lib/csvbuilder/core/concerns/attributes_base.rb', line 45 def hash attributes.hash end |
#original_attribute(column_name) ⇒ Object
Returns the column’s attribute.
33 34 35 |
# File 'lib/csvbuilder/core/concerns/attributes_base.rb', line 33 def original_attribute(column_name) attribute_objects[column_name].try(:value) end |
#to_json(*_args) ⇒ Object
37 38 39 |
# File 'lib/csvbuilder/core/concerns/attributes_base.rb', line 37 def to_json(*_args) attributes.to_json end |