ecoportal-api-v2 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3dba4cd5253cab4decdb13d328fb6f42378dd9f04a6bd9a1f3a29d92b1ea742
4
- data.tar.gz: 711ce1261bb5ca760a6c677d76763b83b1348a224e25479fbb385c603bef0bc8
3
+ metadata.gz: b6294103b68ebdbf099d1137865856b10baec21683bd648727976f245cf197ad
4
+ data.tar.gz: e0500e2c784a46c7a82ca3aa29e44f96d116bd6898e5b35f9174162457208165
5
5
  SHA512:
6
- metadata.gz: cf681ae84a49b6524ddc291a3d73adebbb69fd22a205dd2f8c031e13ee193924de033cb3527c5187a35e68e8c16259e9594cb54822d0c9e09622ac0891cead3b
7
- data.tar.gz: 4eafbc2ff96d1d617f59422f9b06ee05db7360206669403d5defd54ac005c7117edb44ca51e6f9606cd16b7c28f305de0e51badcc89762d1fa0bba0338622253
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.6] - 2024-02-xx
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
@@ -20,3 +20,8 @@ And then execute:
20
20
  Or install it yourself as:
21
21
 
22
22
  $ gem install ecoportal-api-v2
23
+
24
+
25
+ ## Changelog
26
+
27
+ See {file:CHANGELOG.md} for a list of changes.
@@ -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
- raise UnlinkedModel.new("Can't find child: #{value}")
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 invinite loop for `get_key` without setting an
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'
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GEM2_VERSION = "1.1.5"
3
+ GEM2_VERSION = "1.1.6"
4
4
  end
5
5
  end
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.5
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-02 00:00:00.000000000 Z
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
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1