Sha256: 5615d01c1c52f65bbe6a265a340e7ca8a969599d7f15d490bb949fd03126fcd6

Contents?: true

Size: 485 Bytes

Versions: 2

Compression:

Stored size: 485 Bytes

Contents

module Arrest
  class Ref
    include HasAttributes

    attribute :id, String
    attribute :type, String

    def self.mk_json(value)
      self.to_hash.to_json
    end

    def self.to_hash
      {:id => value.id, :type => value.type}
    end
  end

  class PolymorphicAttribute < NestedAttribute
    def initialize name, actions
      super name, Ref, actions
    end

    def from_hash(parent, value)
      return nil unless value != nil
      @clazz.new(value)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arrest-0.0.89 lib/arrest/attributes/polymorphic_attribute.rb
arrest-0.0.88 lib/arrest/attributes/polymorphic_attribute.rb