Class: LpCSVExportable::CSVColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/lp_csv_exportable/csv_column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ CSVColumn

Returns a new instance of CSVColumn.



5
6
7
8
9
10
11
# File 'lib/lp_csv_exportable/csv_column.rb', line 5

def initialize(args = {})
  @header = args[:header]
  @model_method = args[:model_method]
  @model_methods = args[:model_methods]
  @type = args.fetch(:type, :string)
  after_init(args)
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



3
4
5
# File 'lib/lp_csv_exportable/csv_column.rb', line 3

def header
  @header
end

#model_methodObject (readonly)

Returns the value of attribute model_method.



3
4
5
# File 'lib/lp_csv_exportable/csv_column.rb', line 3

def model_method
  @model_method
end

#model_methodsObject (readonly)

Returns the value of attribute model_methods.



3
4
5
# File 'lib/lp_csv_exportable/csv_column.rb', line 3

def model_methods
  @model_methods
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/lp_csv_exportable/csv_column.rb', line 3

def type
  @type
end

Instance Method Details

#format(result) ⇒ Object



13
14
15
16
# File 'lib/lp_csv_exportable/csv_column.rb', line 13

def format(result)
  return send(type, result) if respond_to?(type)
  result
end