Class: AhoyCaptain::ApplicationDecorator
- Inherits:
-
Object
- Object
- AhoyCaptain::ApplicationDecorator
- Defined in:
- app/decorators/ahoy_captain/application_decorator.rb
Direct Known Subclasses
CampaignDecorator, CountryDecorator, DeviceDecorator, PageDecorator, SourceDecorator
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object, context) ⇒ ApplicationDecorator
constructor
A new instance of ApplicationDecorator.
Constructor Details
#initialize(object, context) ⇒ ApplicationDecorator
Returns a new instance of ApplicationDecorator.
28 29 30 31 |
# File 'app/decorators/ahoy_captain/application_decorator.rb', line 28 def initialize(object, context) @object = object @context = context end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'app/decorators/ahoy_captain/application_decorator.rb', line 5 def object @object end |
Class Method Details
.csv_map(params = {}) ⇒ Object
23 24 25 |
# File 'app/decorators/ahoy_captain/application_decorator.rb', line 23 def self.csv_map(params = {}) raise NotImplementedError end |
.to_csv(collection, context) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/decorators/ahoy_captain/application_decorator.rb', line 7 def self.to_csv(collection, context) rows = collection.map { |row| new(row, context) } CSV.generate do |csv| csv << csv_map(context.params).keys rows.each do |row| items = [] csv_map.values.each do |attr| items << row.send(attr) end csv << items end end end |