kwstruct 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/lib/kwstruct.rb +10 -8
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b437daa6c83925a4e6596ca5f1a277a409061dbd
4
- data.tar.gz: 26dcfed74953abc501069b3ab4297e2587893cc7
3
+ metadata.gz: ad3e24f26b36d8bfef2d7d0970e01c5397f69cfb
4
+ data.tar.gz: f149e3d64c1374c5c9daa5aafcc0ff768b7afcdf
5
5
  SHA512:
6
- metadata.gz: 91a469addaf49fb484d3c74d4edcd0492cfc911b2bdac963e2c356f99a4eeb0a833f0e814991700b64e7758ef101fd8270d3bd4f5a40bfd69b410656a78d8286
7
- data.tar.gz: 33440dceab4f8278a55c4ebdd6e5962a18b28c417487cf7906c53764e07bf37f7ae6c832e9c9ad484cf04a9545cb9e986655a76dd0a481caa4b6e17515d581fa
6
+ metadata.gz: 1a818ffaeb8e06b9954a4e4b3af46656e85ea5121f6e3d929e54f320516c9c3d1f7e84bd979ec659c8258333fba83d7672341572c2f6b263edd76e3da4b8f74b
7
+ data.tar.gz: b09f67e65e8861e33cd3283edc643e3e388c377e2ad3806cade0c46dbff312232d66ce5a7aa66858cfd093c378ce6c665f381c2214bab4be0099a2841a8279cc
data/README.md CHANGED
@@ -12,3 +12,7 @@ Any non-existent arguments will raise an ArgumentError.
12
12
  ## Installation
13
13
 
14
14
  $ gem install kwstruct
15
+
16
+ ## Credits
17
+
18
+ Thanks [@apeiros](https://github.com/apeiros) for ideas.
@@ -1,12 +1,14 @@
1
1
  class KwStruct < Struct
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
 
4
- def self.new(*members)
5
- class_eval <<-RUBY
6
- def initialize(#{members.map{|m| "#{m}: nil"}.join(', ')})
7
- super(#{members.join(', ')})
8
- end
9
- RUBY
10
- super
4
+ def self.new(*members, &block)
5
+ super.tap do |struct_class|
6
+ struct_class.class_eval <<-RUBY
7
+ def initialize(#{members.map{|m| "#{m}: nil"}.join(', ')})
8
+ super(#{members.join(', ')})
9
+ end
10
+ RUBY
11
+ end
11
12
  end
12
13
  end
14
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kwstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak