Class: Praxis::Collection

Inherits:
Attributor::Collection
  • Object
show all
Includes:
Types::MediaTypeCommon
Defined in:
lib/praxis/collection.rb

Class Method Summary collapse

Class Method Details

.member_type(type = nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/praxis/collection.rb', line 25

def self.member_type(type=nil)
  unless type.nil?
    @member_type = type
  end

  @member_type
end

.of(type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/praxis/collection.rb', line 5

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

  klass = super

  if type < Praxis::Types::MediaTypeCommon
    unless type.identifier.nil?
      klass.identifier(type.identifier + ';type=collection')
    end

    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