class Praxis::Collection

Public Class Methods

domain_model() click to toggle source
# File lib/praxis/collection.rb, line 41
def self.domain_model
  @member_type.domain_model
end
member_type(type=nil) click to toggle source
# File lib/praxis/collection.rb, line 23
def self.member_type(type=nil)
  unless type.nil?
    @member_type = type
    @views = nil
    self.identifier(type.identifier + ';type=collection') unless type.identifier.nil?
  end

  @member_type
end
of(type) click to toggle source
Calls superclass method
# File lib/praxis/collection.rb, line 5
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
    warn "DEPRECATION: Praxis::Collection.of() for non-MediaTypes will be unsupported in 1.0. Use Attributor::Collection.of() instead."
    Attributor::Collection.of(type)
  end

end
views() click to toggle source
# File lib/praxis/collection.rb, line 33
def self.views
  @views ||= begin
    @member_type.views.each_with_object(Hash.new) do |(name, view), hash|
      hash[name] = Praxis::CollectionView.new(name, @member_type, view)
    end
  end
end