ncore 3.8.1 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- 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: b9823810517052d731b6290cf93b9bd942f25164aed98940860be7c37b7514b5
|
4
|
+
data.tar.gz: 851945716245d8308d5b14a7fc17afb4207ea25f4dff049779ab8e9f2d1a5a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02103dd4eb28433b6311192c37f727e31708a2d5b4ccd2c46888d13a661f6916c906dbd90ad42e03f00592ab6c267fd46d560c69636070a6ee7ddf50c4f4c037
|
7
|
+
data.tar.gz: ee2d1391f5042222d448aebb3ef96f521eb535d3d0e1d23f6bb715bd2cf836f64d6d8a72527d95efd0af05a2881556111000acb5e65082fa8289f605a90ed51d
|
data/CHANGELOG.md
CHANGED
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.0
|
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-02-
|
11
|
+
date: 2024-02-27 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
|