Sha256: f5d771c39acaff95d581d4dfc795b56ef9e6682d770229c4ac2303beae603f01

Contents?: true

Size: 497 Bytes

Versions: 2

Compression:

Stored size: 497 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
      self.clazz.new(value)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arrest-0.0.91 lib/arrest/attributes/polymorphic_attribute.rb
arrest-0.0.90 lib/arrest/attributes/polymorphic_attribute.rb