Sha256: 18f0e9f23c6293f8639bafe297fe29e87fa0936d916f6f97c33d12632cb45656
Contents?: true
Size: 608 Bytes
Versions: 1
Compression:
Stored size: 608 Bytes
Contents
module SmartCsv module Exportable module ClassMethods def self.to_csv(*args) find(:all).to_csv(*args) end end module InstanceMethods def export_columns(format = nil) self.class.content_columns.map(&:name) - ['created_at', 'updated_at'] end def to_row(format = nil) export_columns(format).map { |c| self.send(c) } end end def self.included(receiver) receiver.extend ClassMethods receiver.send :include, InstanceMethods end end end ActiveRecord::Base.send :include, SmartCsv::Exportable
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danielvlopes-smart_csv-0.1.0 | lib/smart_csv/exportable.rb |