Class: Praxis::Collection
- Inherits:
-
Attributor::Collection
- Object
- Attributor::Collection
- Praxis::Collection
- Includes:
- Types::MediaTypeCommon
- Defined in:
- lib/praxis/collection.rb
Class Method Summary collapse
- .as_json_schema(**_args) ⇒ Object
- .domain_model ⇒ Object
- .json_schema_type ⇒ Object
- .member_type(type = nil) ⇒ Object
- .of(type) ⇒ Object
Class Method Details
.as_json_schema(**_args) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/praxis/collection.rb', line 36 def self.as_json_schema(**_args) the_type = @attribute&.type || member_type { type: json_schema_type, items: the_type.as_json_schema } end |
.domain_model ⇒ Object
28 29 30 |
# File 'lib/praxis/collection.rb', line 28 def self.domain_model @member_type.domain_model end |
.json_schema_type ⇒ Object
32 33 34 |
# File 'lib/praxis/collection.rb', line 32 def self.json_schema_type :array end |
.member_type(type = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/praxis/collection.rb', line 19 def self.member_type(type = nil) unless type.nil? @member_type = type identifier("#{type.identifier};type=collection") unless type.identifier.nil? end @member_type end |
.of(type) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/praxis/collection.rb', line 7 def self.of(type) return type::Collection if defined?(type::Collection) klass = super klass.anonymous_type raise 'Praxis::Collection.of() for non-MediaTypes is unsupported. Use Attributor::Collection.of() instead.' unless type < Praxis::Types::MediaTypeCommon klass.member_type type type.const_set :Collection, klass end |