Sha256: 3471e99c9d39932498e2ed25856aa7efb9019ba296f104fd4e3d146654c5273a

Contents?: true

Size: 802 Bytes

Versions: 5

Compression:

Stored size: 802 Bytes

Contents

module Praxis
  class Collection < Attributor::Collection
    include Types::MediaTypeCommon

    def self.of(type)
      if defined?(type::Collection)
        return type::Collection
      end

      klass = super
      klass.anonymous_type

      if type < Praxis::Types::MediaTypeCommon
        klass.member_type type
        type.const_set :Collection, klass
      else
        raise "Praxis::Collection.of() for non-MediaTypes is unsupported. Use Attributor::Collection.of() instead."
      end

    end

    def self.member_type(type=nil)
      unless type.nil?
        @member_type = type
        self.identifier(type.identifier + ';type=collection') unless type.identifier.nil?
      end

      @member_type
    end

    def self.domain_model
      @member_type.domain_model
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
praxis-2.0.pre.14 lib/praxis/collection.rb
praxis-2.0.pre.13 lib/praxis/collection.rb
praxis-2.0.pre.12 lib/praxis/collection.rb
praxis-2.0.pre.11 lib/praxis/collection.rb
praxis-2.0.pre.10 lib/praxis/collection.rb