apia 3.3.1 → 3.4.0
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 +4 -4
- data/lib/apia/field_set.rb +5 -2
- data/lib/apia/generated_hash.rb +30 -0
- data/lib/apia/object.rb +1 -1
- data/lib/apia/version.rb +1 -6
- metadata +3 -3
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f40c9dba04e5b064ced8833f9edb42f96efd59c9d4e9342a4fa6535a1e76c6ee
|
4
|
+
data.tar.gz: 2506e79260735d3c2029ac7eaa9733e481b975b177506f03fcdeba21760b8781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ae74d9f396b7dda8d14513d072f3e7f0902724c5b3e8bd0a430341f8d1e91dd83e4e6aae0b377dc954e3f248c5da7ba3984da354202fa42043c1e5d8d0e5ba7
|
7
|
+
data.tar.gz: 7e735b6a11cfc48325cd60ce0d01a36cb9eb776afeb2b74c3efe8de034b02413df3c8cec149b9ffa0883af4c85d4f631d7cc9f67e63c169e3fbcaeb4d0dbe517
|
data/lib/apia/field_set.rb
CHANGED
@@ -5,6 +5,7 @@ require 'apia/scalar'
|
|
5
5
|
require 'apia/object'
|
6
6
|
require 'apia/enum'
|
7
7
|
require 'apia/field_spec'
|
8
|
+
require 'apia/generated_hash'
|
8
9
|
|
9
10
|
module Apia
|
10
11
|
class FieldSet < Hash
|
@@ -35,10 +36,12 @@ module Apia
|
|
35
36
|
#
|
36
37
|
# @param source [Object, Hash]
|
37
38
|
# @param request [Apia::Request]
|
39
|
+
# @param object [Apia::Object] the object that this fieldset belongs to
|
38
40
|
# @param only [Array]
|
39
41
|
# @return [Hash]
|
40
|
-
def generate_hash(source, request: nil, path: [])
|
41
|
-
|
42
|
+
def generate_hash(source, request: nil, path: [], object: nil)
|
43
|
+
new_hash = GeneratedHash.enabled? ? GeneratedHash.new(object, source, path: path) : {}
|
44
|
+
each_with_object(new_hash) do |(_, field), hash|
|
42
45
|
next unless field.include?(source, request)
|
43
46
|
|
44
47
|
field_path = path + [field]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Apia
|
4
|
+
class GeneratedHash < Hash
|
5
|
+
|
6
|
+
attr_reader :object
|
7
|
+
attr_reader :source
|
8
|
+
attr_reader :path
|
9
|
+
|
10
|
+
def initialize(object, source, path: nil)
|
11
|
+
super()
|
12
|
+
@object = object
|
13
|
+
@source = source
|
14
|
+
@path = path
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
def enabled?
|
20
|
+
@enabled == true
|
21
|
+
end
|
22
|
+
|
23
|
+
def enable
|
24
|
+
@enabled = true
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/apia/object.rb
CHANGED
@@ -49,7 +49,7 @@ module Apia
|
|
49
49
|
# @param request [Apia::Request] the associated request
|
50
50
|
# @return [Hash]
|
51
51
|
def hash(request: nil, path: [])
|
52
|
-
self.class.definition.fields.generate_hash(@value, request: request, path: path)
|
52
|
+
self.class.definition.fields.generate_hash(@value, object: self, request: request, path: path)
|
53
53
|
end
|
54
54
|
|
55
55
|
# Should this type be included in any output?
|
data/lib/apia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -45,7 +45,6 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- VERSION
|
49
48
|
- lib/apia.rb
|
50
49
|
- lib/apia/api.rb
|
51
50
|
- lib/apia/argument_set.rb
|
@@ -110,6 +109,7 @@ files:
|
|
110
109
|
- lib/apia/errors/standard_error.rb
|
111
110
|
- lib/apia/field_set.rb
|
112
111
|
- lib/apia/field_spec.rb
|
112
|
+
- lib/apia/generated_hash.rb
|
113
113
|
- lib/apia/helpers.rb
|
114
114
|
- lib/apia/hook_set.rb
|
115
115
|
- lib/apia/lookup_argument_set.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.3.1
|