ecoportal-api-v2 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +5 -0
- data/lib/ecoportal/api/common/content/collection_model.rb +20 -1
- data/lib/ecoportal/api/common/content/double_model.rb +6 -1
- data/lib/ecoportal/api/v2/registers/page_result/membrane_droplet.rb +15 -0
- data/lib/ecoportal/api/v2/registers/page_result.rb +6 -2
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +3 -3
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6294103b68ebdbf099d1137865856b10baec21683bd648727976f245cf197ad
|
4
|
+
data.tar.gz: e0500e2c784a46c7a82ca3aa29e44f96d116bd6898e5b35f9174162457208165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb18fb2a167afeaea5eac0db4e13ee58d64fc348ff1ebd33942ad1bb7120cbb828ad2652ed2d6b165d7a1b53eea097338032690e26ee97f5765fd87ba2f97862
|
7
|
+
data.tar.gz: 7a61a35335247d39a0e97574f5b2816a92238d93a9f5b23c62b909a92ae03817057752ffc576ae1414c5e6744a6381b473be4cd2cfc2a0fd4e7582cffd97bdd4
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [1.1.
|
4
|
+
## [1.1.7] - 2024-02-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [1.1.6] - 2024-02-29
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- A bit of **specs** on object retrieval for `Ecoportal::API::Common::Conent::CollectionModel`
|
14
|
+
- `Ecoportal::API::Registers::PageResult` exposed `membranes`
|
15
|
+
- with new object `Ecoportal::API::Registers::PageResult::MembraneDroplet`
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- `Ecoportal::API::Common::Conent::CollectionModel`
|
19
|
+
|
10
20
|
## [1.1.5] - 2024-02-03
|
11
21
|
|
12
22
|
### Changed
|
data/README.md
CHANGED
@@ -11,6 +11,8 @@ module Ecoportal
|
|
11
11
|
attr_writer :klass
|
12
12
|
attr_accessor :order_matters, :order_key
|
13
13
|
|
14
|
+
# The attr that has been defined as `passkey`
|
15
|
+
# in the item class
|
14
16
|
def items_key
|
15
17
|
@items_key ||= "id"
|
16
18
|
end
|
@@ -22,6 +24,8 @@ module Ecoportal
|
|
22
24
|
# Resolves to the nuclear `Class` of the elements
|
23
25
|
# @note
|
24
26
|
# - use block to define `klass` callback
|
27
|
+
# @note When `klass` is resolved, if the items are of type
|
28
|
+
# `DoubleModel`, it sets on the collection class the `items_key`
|
25
29
|
# @param value [Hash] base `doc` (raw object) to create the object with
|
26
30
|
# @yield [doc] identifies the target `class` of the raw object
|
27
31
|
# @yieldparam doc [Hash]
|
@@ -31,6 +35,7 @@ module Ecoportal
|
|
31
35
|
if block
|
32
36
|
@klass = block
|
33
37
|
block.call(value) if value != NOT_USED
|
38
|
+
@klass
|
34
39
|
elsif used_param?(value)
|
35
40
|
if @klass.is_a?(Proc)
|
36
41
|
@klass.call(value)
|
@@ -39,6 +44,10 @@ module Ecoportal
|
|
39
44
|
end
|
40
45
|
else
|
41
46
|
resolve_class(@klass, exception: false)
|
47
|
+
end.tap do |result|
|
48
|
+
next unless result.is_a?(Class)
|
49
|
+
next unless result < Ecoportal::API::Common::Content::DoubleModel
|
50
|
+
self.items_key = result.key
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
@@ -127,7 +136,17 @@ module Ecoportal
|
|
127
136
|
#print "{{#{p}}}"
|
128
137
|
end
|
129
138
|
else
|
130
|
-
|
139
|
+
show_str = \
|
140
|
+
case value
|
141
|
+
when Hash
|
142
|
+
value.pretty_inspect
|
143
|
+
when Content::DoubleModel
|
144
|
+
"#{value} with key: #{value.class.key} (items_key: #{self.class.items_key})"
|
145
|
+
else
|
146
|
+
value
|
147
|
+
end
|
148
|
+
|
149
|
+
raise UnlinkedModel, "Can't find child: #{show_str}"
|
131
150
|
end
|
132
151
|
end
|
133
152
|
|
@@ -28,6 +28,8 @@ module Ecoportal
|
|
28
28
|
!!key
|
29
29
|
end
|
30
30
|
|
31
|
+
# key property (and method) of this model
|
32
|
+
# @note this is auto-set when `passkey` is used
|
31
33
|
def key=(value)
|
32
34
|
@key = value.to_s.freeze
|
33
35
|
end
|
@@ -72,7 +74,7 @@ module Ecoportal
|
|
72
74
|
# This method is essential to give stability to the model
|
73
75
|
# @note `Content::CollectionModel` needs to find elements in the doc `Array`.
|
74
76
|
# The only way to do it is via the access key (i.e. `id`). However, there is
|
75
|
-
# no chance you can avoid
|
77
|
+
# no chance you can avoid infinite loop for `get_key` without setting an
|
76
78
|
# instance variable key at the moment of the object creation, when the
|
77
79
|
# `doc` is firstly received
|
78
80
|
# @param method [Symbol] the method that exposes the value
|
@@ -263,6 +265,7 @@ module Ecoportal
|
|
263
265
|
|
264
266
|
inheritable_class_vars :forced_model_keys, :key
|
265
267
|
|
268
|
+
# `_key` refers to the parent's property that links to this model
|
266
269
|
attr_reader :_parent, :_key, :_read_only
|
267
270
|
|
268
271
|
def initialize(doc = {}, parent: self, key: nil, read_only: false)
|
@@ -321,6 +324,8 @@ module Ecoportal
|
|
321
324
|
if is_root?
|
322
325
|
@doc
|
323
326
|
else
|
327
|
+
# transform parent's `_key` to this object into a
|
328
|
+
# path key that can rerieve from the parents's doc
|
324
329
|
_parent.doc.dig(*[_doc_key(_key)].flatten)
|
325
330
|
end
|
326
331
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Registers
|
5
|
+
class PageResult
|
6
|
+
class MembraneDroplet < Common::Content::DoubleModel
|
7
|
+
passkey :ref
|
8
|
+
passthrough :label, :type, :value
|
9
|
+
passthrough :field_configuration_id
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -12,10 +12,14 @@ module Ecoportal
|
|
12
12
|
passthrough :mould_counter
|
13
13
|
|
14
14
|
class_resolver :stages_class, "Ecoportal::API::V2::Registers::StagesResult"
|
15
|
-
embeds_many :stages, enum_class: :stages_class
|
16
|
-
end
|
15
|
+
embeds_many :stages, enum_class: :stages_class, read_only: true
|
17
16
|
|
17
|
+
class_resolver :mem_droplet, "Ecoportal::API::V2::Registers::PageResult::MembraneDroplet"
|
18
|
+
embeds_many :membranes, klass: :mem_droplet, read_only: true
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
24
|
+
|
25
|
+
require_relative 'page_result/membrane_droplet'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api-v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,7 +156,6 @@ files:
|
|
156
156
|
- ".gitignore"
|
157
157
|
- ".rspec"
|
158
158
|
- ".rubocop.yml"
|
159
|
-
- ".travis.yml"
|
160
159
|
- ".yardopts"
|
161
160
|
- CHANGELOG.md
|
162
161
|
- Gemfile
|
@@ -242,6 +241,7 @@ files:
|
|
242
241
|
- lib/ecoportal/api/v2/people.rb
|
243
242
|
- lib/ecoportal/api/v2/registers.rb
|
244
243
|
- lib/ecoportal/api/v2/registers/page_result.rb
|
244
|
+
- lib/ecoportal/api/v2/registers/page_result/membrane_droplet.rb
|
245
245
|
- lib/ecoportal/api/v2/registers/register.rb
|
246
246
|
- lib/ecoportal/api/v2/registers/search_results.rb
|
247
247
|
- lib/ecoportal/api/v2/registers/stage_result.rb
|