ncore 3.8.0 → 3.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c93d49d552806a8439994a201a54ae1550be771c5ba3e855131317267492efb
4
- data.tar.gz: a20b77b20173293816a3a2f753561b3cfc0a962644db0696f4a2f5d7dedf024d
3
+ metadata.gz: 0b92860b930948dd670a333583cd9e20ce4608929eb0c5f968234fe0cace69d3
4
+ data.tar.gz: 00e9f32713a037614ff36b322600b95338e23957ed165388c69269a4f9c129df
5
5
  SHA512:
6
- metadata.gz: 9ef44487b9cc0def0b5dc9be8f34bac4a13ae3fd1226f5e2d87d1a02cc111d52565a142a92e7619493b9d236eb68837832b9eee62e6fdae86b0bc2c0cf64d44f
7
- data.tar.gz: 9337020d9f962ef43852d859981fa2f67a198fd51f6ad3ced23ecbc4aeafea6ff4b67b651abf41e0868ede636490383dd4e7746c2607ed0bf4b4f01c9c03ab0f
6
+ metadata.gz: fdaddd93c446f6c57d76d490f742d64683e1218f1c9628b2fb6de984d1fc586911746f9f7ffb126e057ffc5b3d57d896bbea3545d1e99276499743b1b884d95b
7
+ data.tar.gz: d5af6a87561366c3fc1e92823dd64e281016b8c3b0128edd17998b7ae48879eb590f0b9ca56a6b342baa98784cac7b3aeea8a4418631ae12b0b0f0607ae24eee
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ #### 3.8.1
2
+
3
+ - Add option to disable some_attr?() definition
4
+
1
5
  #### 3.8.0
2
6
 
3
7
  - Add has_one association helper
@@ -11,25 +11,22 @@ module NCore
11
11
  # attr(:name, ...)
12
12
  # adds: obj.name => raw json type
13
13
  # obj.name? => bool
14
- def attr(*attrs)
14
+ def attr(*attrs, predicate: true)
15
15
  attrs.each do |attr|
16
16
  check_existing_method(attr)
17
17
  class_eval <<-AR, __FILE__, __LINE__+1
18
18
  def #{attr}
19
19
  self[:#{attr}]
20
20
  end
21
-
22
- def #{attr}?
23
- !! self[:#{attr}]
24
- end
25
21
  AR
22
+ attr_boolean :"#{attr}?" if predicate
26
23
  end
27
24
  end
28
25
 
29
26
  # attr_datetime(:updated_at, ...)
30
27
  # adds: obj.updated_at => Time, or raw json type if not parseable
31
28
  # obj.updated_at? => bool
32
- def attr_datetime(*attrs)
29
+ def attr_datetime(*attrs, predicate: true)
33
30
  attrs.each do |attr|
34
31
  check_existing_method(attr)
35
32
  class_eval <<-AD, __FILE__, __LINE__+1
@@ -45,18 +42,15 @@ module NCore
45
42
  rescue ArgumentError, TypeError
46
43
  self[:#{attr}]
47
44
  end
48
-
49
- def #{attr}?
50
- !! self[:#{attr}]
51
- end
52
45
  AD
46
+ attr_boolean :"#{attr}?" if predicate
53
47
  end
54
48
  end
55
49
 
56
50
  # attr_decimal(:amount, ...)
57
51
  # adds: obj.amount => BigMoney if String, else raw json type
58
52
  # obj.amount? => bool
59
- def attr_decimal(*attrs)
53
+ def attr_decimal(*attrs, predicate: true)
60
54
  attrs.each do |attr|
61
55
  check_existing_method(attr)
62
56
  class_eval <<-AD, __FILE__, __LINE__+1
@@ -68,11 +62,22 @@ module NCore
68
62
  self[:#{attr}]
69
63
  end
70
64
  end
65
+ AD
66
+ attr_boolean :"#{attr}?" if predicate
67
+ end
68
+ end
71
69
 
72
- def #{attr}?
73
- !! self[:#{attr}]
70
+ # attr_boolean(:active, :active?, ...)
71
+ # adds: obj.active
72
+ # adds: obj.active? - in attrs hash, this looks for the key :active, not :active?
73
+ def attr_boolean(*attrs)
74
+ attrs.each do |attr|
75
+ check_existing_method(attr)
76
+ class_eval <<-AB, __FILE__, __LINE__+1
77
+ def #{attr}
78
+ !! self[:#{attr.to_s.sub(/\?$/,'')}]
74
79
  end
75
- AD
80
+ AB
76
81
  end
77
82
  end
78
83
 
data/lib/ncore/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NCore
2
- VERSION = '3.8.0'
2
+ VERSION = '3.8.1'
3
3
  end
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.8.0
4
+ version: 3.8.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-01-31 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.4.10
145
+ rubygems_version: 3.5.3
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: NCore - Gem for building REST API clients