l43_open_object 0.2.2 → 0.2.3

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: b3fd83f7a3355c0740be183a64fb5dc69b57829ac953f08258aeb83b1d9fcdad
4
- data.tar.gz: 2c93657c412878854ebc9e371e6a57a66d2ce0594a6cfe07a52fdda8d6ecb43e
3
+ metadata.gz: 10bdaa5f61e9a0308915ebc819a135797dffd5e42c903387400422aed4250144
4
+ data.tar.gz: 750a314d9770f6cacfde3ca3427332a4bd9ddf534bef2f3493c235a23f4addfa
5
5
  SHA512:
6
- metadata.gz: 33fb3f9a98acf4cd0ed278ce46d16fcb92bb01d581ab161c271999bee012bec0a3c6716adc9e921ac4cbc9e7619ffc6db67d465f6df65b87c28d7ce523fdd3be
7
- data.tar.gz: 150a6bf8b7db2c5d18e9306ba6b08636bc5e699a22e0204389ecf9b2084f58554c607a16082215a549b88e1f483194e59d40979337f4d1cb355e601a442fac23
6
+ metadata.gz: 8e0fff087431d0d1104b97c7b6df5acd4c5335db87b9c0d2283c1300b5f4cf46832ad243fb98f5fc357dd893de349170af2fc43540422c7b229fdb3f16c68e68
7
+ data.tar.gz: b90aa376adf4f41d82ba86d8d22a03d04b447385ac0232029f12a0bc41b665405ea02051def0b4959bcd05ec33c0fc9021445756d7fc72ed71fae76efe623df7
@@ -25,6 +25,22 @@ module L43
25
25
  raise ArgumentError, "cannot update attribute #{attribute.inspect} without a block" unless blk
26
26
  update(attribute => blk.(to_h[attribute]))
27
27
  end
28
+
29
+ def update_attribute_if(attribute, condition, &blk)
30
+ if condition
31
+ update(attribute => blk.(self))
32
+ else
33
+ self
34
+ end
35
+ end
36
+
37
+ def update_attribute_unless(attribute, condition, &blk)
38
+ if condition
39
+ self
40
+ else
41
+ update(attribute => blk.(self))
42
+ end
43
+ end
28
44
  end
29
45
  end
30
46
  end
@@ -4,7 +4,7 @@ require_relative 'open_object/initializer'
4
4
  require_relative 'open_object/behavior'
5
5
  module L43
6
6
  module OpenObject
7
- VERSION = "0.2.2"
7
+ VERSION = "0.2.3"
8
8
 
9
9
  def attributes(*atts, **defaults, &blk)
10
10
  attr_reader(*atts)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l43_open_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-03-07 00:00:00.000000000 Z
10
+ date: 2026-03-26 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: |-
13
13
  When using the class method `attributes` in a class you get:
@@ -37,14 +37,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.3.0
40
+ version: 4.0.1
41
41
  required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 4.0.3
47
+ rubygems_version: 4.0.9
48
48
  specification_version: 4
49
49
  summary: Define attributes with potential defaults, get all the goodies...
50
50
  test_files: []