Sha256: 83ef9ce3ecef93aa0785cd204bd9fb0016d369f3041dca4bd68c6167255f6ac5

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

class Object
  if Class.respond_to?(:class_attribute)
    class_attribute :comma_formats
  else
    #TODO : Rails 2.3.x Deprecation
    #Deprecated method for class accessors - Maintained for those still on Rails 2.3.x
    class_inheritable_accessor :comma_formats
  end

  def self.comma(style = :default, &block)
    (self.comma_formats ||= {})[style] = block
  end

  def to_comma(style = :default)
    raise "No comma format for class #{self.class} defined for style #{style}" unless self.comma_formats and self.comma_formats[style]
    Comma::DataExtractor.new(self, &self.comma_formats[style]).results
  end

  def to_comma_headers(style = :default)
    raise "No comma format for class #{self.class} defined for style #{style}" unless self.comma_formats and self.comma_formats[style]
    Comma::HeaderExtractor.new(self, &self.comma_formats[style]).results
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comma-0.5.2 lib/comma/object.rb