Sha256: 7754efc0a69317444feebd36d2c4932b547503033f53008907ec88ae925f3d8c

Contents?: true

Size: 768 Bytes

Versions: 15

Compression:

Stored size: 768 Bytes

Contents

require 'yaml'
require 'ardm/property/text'
require 'ardm/property/support/dirty_minder'

module Ardm
  class Property
    class Yaml < Text
      load_as ::Object

      def load(value)
        if value.nil?
          nil
        elsif value.is_a?(::String)
          ::YAML.load(value)
        else
          raise ArgumentError, '+value+ of a property of YAML type must be nil or a String'
        end
      end

      def dump(value)
        if value.nil?
          nil
        elsif value.is_a?(::String) && value =~ /^---/
          value
        else
          ::YAML.dump(value)
        end
      end

      def typecast(value)
        value
      end

      include ::Ardm::Property::DirtyMinder

    end # class Yaml
  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/yaml.rb
ardm-0.4.0 lib/ardm/property/yaml.rb
ardm-0.3.2 lib/ardm/property/yaml.rb
ardm-0.3.1 lib/ardm/property/yaml.rb
ardm-0.3.0 lib/ardm/property/yaml.rb
ardm-0.2.7 lib/ardm/property/yaml.rb
ardm-0.2.6 lib/ardm/property/yaml.rb
ardm-0.2.5 lib/ardm/property/yaml.rb
ardm-0.2.4 lib/ardm/property/yaml.rb
ardm-0.2.3 lib/ardm/property/yaml.rb
ardm-0.2.2 lib/ardm/property/yaml.rb
ardm-0.2.1 lib/ardm/property/yaml.rb
ardm-0.2.0 lib/ardm/property/yaml.rb
ardm-0.1.0 lib/ardm/property/yaml.rb
ardm-0.0.1 lib/ardm/property/yaml.rb