class-cattr 0.1.2 → 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/lib/base.rb +10 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1eda23fbd2a8040014f38211ae51181dd37c990f936860a8934e2b1a37912d22
4
- data.tar.gz: 47027b1c8fc3a495160c792a85cc99d6a25ac1daa2adbf49f24c3944665f7785
3
+ metadata.gz: e5b8ee894264312e37f4ab8c50c9b968f78daa42bf099cb83a10bea0110074da
4
+ data.tar.gz: 71287dd412409772d3ca15f9260da2b9bdf419164644088d13552f9d5db4ad54
5
5
  SHA512:
6
- metadata.gz: 1756b3182dbaf2557ce40abf8266acdb32bdfec4b6261f260c9abfc5695556a7bc03f9beddce6893f02c9c50619551418fa75953c745b8663aa00a9cad75545a
7
- data.tar.gz: a382bb28e40f6e9b3cfed71456cd1d24debd0c458ed6282a51b8247cba29671a8746f5f63d0b722881028cf12bdd366ee30d24e7f3442cc8444afb2f9d1f29d3
6
+ metadata.gz: 88948b3e2d2a34b3d153dcdbafcf054159c5b01d55ce2f6c7b4212d39cc5256a1f1b53507eec4dcc41bfe3a903e9d22f16162be492040c56f59179c025c52901
7
+ data.tar.gz: 786b42b9e22806b4aa3ab92d45f0706f613c1c1439e6b9dd7c06dedd4fdfcd9775bcb26732acb183e21b6ec2d176d2f81fafdad48f9a90c16b0d418209981702
data/.version CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/lib/lib/base.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  class Class
2
- def cattr name = nil, create_class_method = true
3
- if name && create_class_method == true
2
+ def cattr name = nil, value = nil, &block
3
+ return CattrProxy.new(self) unless name
4
+
5
+ if !value.nil? || block
4
6
  define_singleton_method(name) do |arg = :_nil|
5
7
  if arg == :_nil
6
8
  CattrProxy.new(self).send(name)
@@ -8,12 +10,14 @@ class Class
8
10
  CattrProxy.new(self).send('%s=' % name, arg)
9
11
  end
10
12
  end
11
- end
12
13
 
13
- if name
14
- CattrProxy.new(self).send('%s=' % name, nil)
14
+ if !value.nil?
15
+ CattrProxy.new(self).send('%s=' % name, value)
16
+ elsif block
17
+ CattrProxy.new(self).send(name, value, &block)
18
+ end
15
19
  else
16
- CattrProxy.new(self)
20
+ CattrProxy.new(self).send('%s=' % name, nil)
17
21
  end
18
22
  end
19
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class-cattr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic