Module: ToCsv

Extended by:
ActiveSupport::Concern
Defined in:
lib/to_csv.rb,
lib/to_csv/version.rb,
lib/to_csv/interceptor.rb

Defined Under Namespace

Modules: ClassMethods Classes: Interceptor

Constant Summary collapse

VERSION =
"0.3.0"

Instance Method Summary collapse

Instance Method Details

#to_csv(namespace = :default) ⇒ Object



21
22
23
24
25
# File 'lib/to_csv.rb', line 21

def to_csv(namespace = :default)
  Interceptor.from(self).to_block(&csv_instructions[namespace]).with_result do |results,methods|
    CSV::generate_line(results)
  end
end

#to_csv_header(namespace = :default) ⇒ Object



27
28
29
30
31
# File 'lib/to_csv.rb', line 27

def to_csv_header(namespace = :default)
  Interceptor.from(self).to_block(&csv_instructions[namespace]).with_result do |results,methods|
    CSV::generate_line(methods)
  end
end