Sha256: 229d5cb739a5fcaf17e886b27d0f8ea8c8a048fe292ed5b976641d191530bb32

Contents?: true

Size: 466 Bytes

Versions: 26

Compression:

Stored size: 466 Bytes

Contents

module DataMapper
  class Property

    class ParsePointer < Object

      def dump(value)
        value && {"__type" => "Pointer", "className" => target_storage_name, "objectId" => value.to_s}
      end

      def load(value)
        value.is_a?(Hash) ? value["objectId"] : super
      end

      private
      def target_storage_name
        model.relationships.select { |r| r.child_key.include? self }.first.parent_model.storage_name
      end
    end

  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dm-parse-0.3.20 lib/property/parse_pointer.rb
dm-parse-0.3.19 lib/property/parse_pointer.rb
dm-parse-0.3.18 lib/property/parse_pointer.rb
dm-parse-0.3.17 lib/property/parse_pointer.rb
dm-parse-0.3.16 lib/property/parse_pointer.rb
dm-parse-0.3.15 lib/property/parse_pointer.rb
dm-parse-0.3.14 lib/property/parse_pointer.rb
dm-parse-0.3.13 lib/property/parse_pointer.rb
dm-parse-0.3.12 lib/property/parse_pointer.rb
dm-parse-0.3.11 lib/property/parse_pointer.rb
dm-parse-0.3.10 lib/property/parse_pointer.rb
dm-parse-0.3.9 lib/property/parse_pointer.rb
dm-parse-0.3.8 lib/property/parse_pointer.rb
dm-parse-0.3.7 lib/property/parse_pointer.rb
dm-parse-0.3.6 lib/property/parse_pointer.rb
dm-parse-0.3.5 lib/property/parse_pointer.rb
dm-parse-0.3.4 lib/property/parse_pointer.rb
dm-parse-0.3.3 lib/property/parse_pointer.rb
dm-parse-0.3.2 lib/property/parse_pointer.rb
dm-parse-0.3.1 lib/property/parse_pointer.rb