ncore 3.8.1 → 3.9.1
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/CHANGELOG.md +9 -0
- data/lib/ncore/associations.rb +5 -1
- data/lib/ncore/attributes.rb +1 -1
- data/lib/ncore/base.rb +4 -1
- data/lib/ncore/client.rb +14 -5
- data/lib/ncore/filter_attributes.rb +43 -0
- data/lib/ncore/singleton_base.rb +3 -0
- data/lib/ncore/util.rb +0 -13
- data/lib/ncore/version.rb +1 -1
- data/lib/ncore.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b66817fa03001d9f131ac934006e7923e13a7838119b300cfdab0a724408615b
|
|
4
|
+
data.tar.gz: 25e8291db6f8881a8f4f712c1920d7dd4498ebd192ecb1b35089fecb47afc8c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8d67db0031bcd320a5a7a62adebea3ce736d7ab64c012fab747d6024db6e2bb106ab8735ad2ebca02ff073cc40e7138060342e9741db0ef3131dffd4bbf97dc
|
|
7
|
+
data.tar.gz: f72ee77da4f993d036a175d0f7474c62583104e8e49bc6cce19f4beefe48f66c71f75b927953eb88aa267fec9dd7b9766c0ab0bbd1208487516439cfef4fc16f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
#### 3.9.1
|
|
2
|
+
|
|
3
|
+
- Fix clearing of memoized association when assoc_id changes
|
|
4
|
+
|
|
5
|
+
#### 3.9.0
|
|
6
|
+
|
|
7
|
+
- Add inspection filter for attributes
|
|
8
|
+
- Fix generation of query params when values are Hashes
|
|
9
|
+
|
|
1
10
|
#### 3.8.1
|
|
2
11
|
|
|
3
12
|
- Add option to disable some_attr?() definition
|
data/lib/ncore/associations.rb
CHANGED
|
@@ -222,9 +222,13 @@ module NCore
|
|
|
222
222
|
end
|
|
223
223
|
P1
|
|
224
224
|
|
|
225
|
+
# private def parent_id=(val)
|
|
226
|
+
# if :parent_key changes, clear memoized association
|
|
225
227
|
class_eval <<-P2, __FILE__, __LINE__+1
|
|
226
228
|
def #{parent_key}=(v)
|
|
227
|
-
@attribs[:#{
|
|
229
|
+
if @attribs[:#{parent_key}] != v and @attribs[:#{assoc_name}]&.id != v
|
|
230
|
+
@attribs[:#{assoc_name}] = nil
|
|
231
|
+
end
|
|
228
232
|
@attribs[:#{parent_key}] = v
|
|
229
233
|
end
|
|
230
234
|
private :#{parent_key}=
|
data/lib/ncore/attributes.rb
CHANGED
|
@@ -201,7 +201,7 @@ module NCore
|
|
|
201
201
|
args[:data].each do |k,v|
|
|
202
202
|
if k=='metadata' || k=='errors'
|
|
203
203
|
@attribs[k] = self.class.interpret_type(v, api_creds)
|
|
204
|
-
elsif respond_to?("#{k}=")
|
|
204
|
+
elsif respond_to?("#{k}=", true)
|
|
205
205
|
send "#{k}=", self.class.interpret_type(v, api_creds)
|
|
206
206
|
else
|
|
207
207
|
@attribs[k] = self.class.interpret_type(v, api_creds)
|
data/lib/ncore/base.rb
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
module NCore
|
|
2
2
|
module Base
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
included do
|
|
6
6
|
extend Associations
|
|
7
7
|
include ActiveModel
|
|
8
8
|
include Attributes
|
|
9
9
|
include Client
|
|
10
10
|
include Client::Cache
|
|
11
|
+
include FilterAttributes
|
|
11
12
|
include Identity
|
|
12
13
|
include Lifecycle
|
|
13
14
|
include Util
|
|
14
15
|
include Wait
|
|
16
|
+
|
|
17
|
+
self.filter_attributes = []
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
module ClassMethods
|
data/lib/ncore/client.rb
CHANGED
|
@@ -88,17 +88,26 @@ module NCore
|
|
|
88
88
|
|
|
89
89
|
def build_query_string(params)
|
|
90
90
|
if params.any?
|
|
91
|
-
query_string = params.sort.
|
|
92
|
-
|
|
91
|
+
query_string = params.sort.filter_map do |k,v|
|
|
92
|
+
case v
|
|
93
|
+
when Array
|
|
93
94
|
if v.empty?
|
|
94
|
-
"#{k.to_s}[]
|
|
95
|
+
"#{CGI::escape(k.to_s)}[]"
|
|
95
96
|
else
|
|
96
97
|
v.sort.map do |v2|
|
|
97
|
-
"#{k.to_s}[]=#{CGI::escape(v2.to_s)}"
|
|
98
|
+
"#{CGI::escape(k.to_s)}[]=#{CGI::escape(v2.to_s)}"
|
|
99
|
+
end.join('&')
|
|
100
|
+
end
|
|
101
|
+
when Hash
|
|
102
|
+
if v.empty?
|
|
103
|
+
nil
|
|
104
|
+
else
|
|
105
|
+
v.sort.map do |k2, v2|
|
|
106
|
+
"#{CGI::escape(k.to_s)}[#{k2}]=#{CGI::escape(v2.to_s)}"
|
|
98
107
|
end.join('&')
|
|
99
108
|
end
|
|
100
109
|
else
|
|
101
|
-
"#{k.to_s}=#{CGI::escape(v.to_s)}"
|
|
110
|
+
"#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}"
|
|
102
111
|
end
|
|
103
112
|
end.join('&')
|
|
104
113
|
"?#{query_string}"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module NCore
|
|
2
|
+
module FilterAttributes
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
module ClassMethods
|
|
6
|
+
|
|
7
|
+
def filter_attributes
|
|
8
|
+
@filter_attributes || superclass.filter_attributes
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def filter_attributes=(filter_attributes)
|
|
12
|
+
@inspection_filter = nil
|
|
13
|
+
@filter_attributes = filter_attributes
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def inspection_filter
|
|
17
|
+
if @filter_attributes
|
|
18
|
+
@inspection_filter ||= ActiveSupport::ParameterFilter.new @filter_attributes
|
|
19
|
+
else
|
|
20
|
+
superclass.inspection_filter
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def inspect
|
|
28
|
+
base = "#{self.class}:0x#{'%016x'%self.object_id} id: #{id.inspect}"
|
|
29
|
+
inspect_chain = Thread.current[:inspect_chain] ||= []
|
|
30
|
+
return "#<#{base}, ...>" if inspect_chain.include? self
|
|
31
|
+
begin
|
|
32
|
+
inspect_chain.push self
|
|
33
|
+
attribs = @attribs.except(:id).each.with_object({}) do |(k,v),h|
|
|
34
|
+
h[k] = v.nil? ? nil : self.class.inspection_filter.filter_param(k,v)
|
|
35
|
+
end
|
|
36
|
+
"#<#{base}, attribs: #{attribs.inspect}, metadata: #{metadata.inspect}>"
|
|
37
|
+
ensure
|
|
38
|
+
inspect_chain.pop
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/ncore/singleton_base.rb
CHANGED
data/lib/ncore/util.rb
CHANGED
|
@@ -63,18 +63,5 @@ module NCore
|
|
|
63
63
|
|
|
64
64
|
delegate :factory, to: :class
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
def inspect
|
|
68
|
-
base = "#{self.class}:0x#{'%016x'%self.object_id} id: #{id.inspect}"
|
|
69
|
-
@@inspect_chain ||= []
|
|
70
|
-
return "#<#{base}, ...>" if @@inspect_chain.include? self
|
|
71
|
-
begin
|
|
72
|
-
@@inspect_chain.push self
|
|
73
|
-
"#<#{base}, attribs: #{@attribs.except(:id).inspect}, metadata: #{metadata.inspect}>"
|
|
74
|
-
ensure
|
|
75
|
-
@@inspect_chain.pop
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
66
|
end
|
|
80
67
|
end
|
data/lib/ncore/version.rb
CHANGED
data/lib/ncore.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ncore
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Notioneer Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -101,6 +101,7 @@ files:
|
|
|
101
101
|
- lib/ncore/collection.rb
|
|
102
102
|
- lib/ncore/configuration.rb
|
|
103
103
|
- lib/ncore/exceptions.rb
|
|
104
|
+
- lib/ncore/filter_attributes.rb
|
|
104
105
|
- lib/ncore/identity.rb
|
|
105
106
|
- lib/ncore/lifecycle.rb
|
|
106
107
|
- lib/ncore/methods/all.rb
|