Sha256: 50915ddd4796dfd9ecb7c3dea438490ed7b899403723907811ad37f0304ccaa6

Contents?: true

Size: 719 Bytes

Versions: 15

Compression:

Stored size: 719 Bytes

Contents

require 'ardm/property/string'
require 'ardm/property/support/dirty_minder'

if RUBY_VERSION >= '1.9.0'
  require 'csv'
else
  require 'fastercsv'  # must be ~>1.5
  CSV = FasterCSV unless defined?(CSV)
end

module Ardm
  class Property
    class Csv < String
      load_as ::Array

      def load(value)
        case value
        when ::String then CSV.parse(value)
        when ::Array  then value
        end
      end

      def dump(value)
        case value
          when ::Array
            CSV.generate { |csv| value.each { |row| csv << row } }
          when ::String then value
        end
      end

      include ::Ardm::Property::DirtyMinder

    end # class Csv
  end # class Property
end # module Ardm

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 lib/ardm/property/csv.rb
ardm-0.4.0 lib/ardm/property/csv.rb
ardm-0.3.2 lib/ardm/property/csv.rb
ardm-0.3.1 lib/ardm/property/csv.rb
ardm-0.3.0 lib/ardm/property/csv.rb
ardm-0.2.7 lib/ardm/property/csv.rb
ardm-0.2.6 lib/ardm/property/csv.rb
ardm-0.2.5 lib/ardm/property/csv.rb
ardm-0.2.4 lib/ardm/property/csv.rb
ardm-0.2.3 lib/ardm/property/csv.rb
ardm-0.2.2 lib/ardm/property/csv.rb
ardm-0.2.1 lib/ardm/property/csv.rb
ardm-0.2.0 lib/ardm/property/csv.rb
ardm-0.1.0 lib/ardm/property/csv.rb
ardm-0.0.1 lib/ardm/property/csv.rb