Class: Eco::API::Organization::NodeClassifications
Constant Summary
Language::Models::Collection::BASIC_METHODS, Language::Models::Collection::EXTENDED_METHODS
Instance Method Summary
collapse
#<, #<<, #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(types = [], klass: Ecoportal::API::GraphQL::Base::LocationClassificationType) ⇒ NodeClassifications
rubocop:disable Lint/UnusedMethodArgument
8
9
10
11
12
13
14
15
|
# File 'lib/eco/api/organization/node_classifications.rb', line 8
def initialize(types = [], klass: Ecoportal::API::GraphQL::Base::LocationClassificationType) @klass = Ecoportal::API::GraphQL::Base::LocationClassificationType
@caches_init = false
super(types, klass: @klass)
init_caches
end
|
Instance Method Details
#[](id_name) ⇒ Object
51
52
53
|
# File 'lib/eco/api/organization/node_classifications.rb', line 51
def [](id_name)
@by_id[type_id(id_name)]
end
|
17
18
19
|
# File 'lib/eco/api/organization/node_classifications.rb', line 17
def ids
@items.map(&:id)
end
|
21
22
23
|
# File 'lib/eco/api/organization/node_classifications.rb', line 21
def names
@items.map(&:name)
end
|
#to_id(name) ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/eco/api/organization/node_classifications.rb', line 25
def to_id(name)
case name
when Enumerable
name.map do |n|
type(n)&.id
end.compact
else
type(name)&.id
end
end
|
#to_name(id) ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/eco/api/organization/node_classifications.rb', line 36
def to_name(id)
case id
when Enumerable
id.map do |n|
type(n)&.name
end.compact
else
type(id)&.name
end
end
|
#type(id_name) ⇒ Object
47
48
49
|
# File 'lib/eco/api/organization/node_classifications.rb', line 47
def type(id_name)
self[id_name]
end
|