Class: Eco::API::Organization::PersonSchemas
- Inherits:
-
Language::Models::Collection
- Object
- Language::Models::Collection
- Eco::API::Organization::PersonSchemas
- Defined in:
- lib/eco/api/organization/person_schemas.rb
Constant Summary
Constants inherited from Language::Models::Collection
Language::Models::Collection::BASIC_METHODS, Language::Models::Collection::EXTENDED_METHODS
Instance Method Summary collapse
-
#initialize(schemas = [], klass: Ecoportal::API::Internal::PersonSchema) ⇒ PersonSchemas
constructor
A new instance of PersonSchemas.
- #schema(id_name) ⇒ Object
- #to_id(name) ⇒ Object
- #to_name(id) ⇒ Object
Methods inherited from Language::Models::Collection
#<, #<<, #attr, #attr?, attr_collection, attr_presence, #attrs, attrs_create_method, #contains, #delete!, #each, #empty, #empty?, #exclude, #group_by, #length, #merge, #new, #newFrom, #present, #present_all?, #present_some?, #remove, #to_c, #to_h, #unique_attrs, #update
Constructor Details
#initialize(schemas = [], klass: Ecoportal::API::Internal::PersonSchema) ⇒ PersonSchemas
Returns a new instance of PersonSchemas.
8 9 10 11 12 13 |
# File 'lib/eco/api/organization/person_schemas.rb', line 8 def initialize(schemas = [], klass: Ecoportal::API::Internal::PersonSchema) @klass = Ecoportal::API::Internal::PersonSchema @caches_init = false super(schemas, klass: @klass) init_caches end |
Instance Method Details
#schema(id_name) ⇒ Object
30 31 32 |
# File 'lib/eco/api/organization/person_schemas.rb', line 30 def schema(id_name) @by_id.fetch(schema_id(id_name), nil) end |
#to_id(name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/eco/api/organization/person_schemas.rb', line 15 def to_id(name) case name when Enumerable name.map do |n| schema(n)&.id end.compact else schema(name)&.id end end |
#to_name(id) ⇒ Object
26 27 28 |
# File 'lib/eco/api/organization/person_schemas.rb', line 26 def to_name(id) schema(id)&.name end |