smart_init 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34a07f2fa3876c9ca80bb60bf76e045aa0c96f408abb6f761c8b80a5d988806a
4
- data.tar.gz: ca8b35191d340a1a43138e7698c8c0bd6f8f1d3d90787d252bf67d66e33e1f22
3
+ metadata.gz: 81cc9ffbde7cec66828bcbb93ed817974a36c124b24ed41b375c15153c7cbb87
4
+ data.tar.gz: 1c008ff8b237652378db6108e0c9e545b7b34663001a56f592955537f2bf826a
5
5
  SHA512:
6
- metadata.gz: 10780f72f2f6e43497fe4fbde549cfdd4cedf7db3c704bad8cc44f0c21f296d34e374bda479cd81835df1a44bac06708500ab4dcaa47ac3ec469ecc6341e66ce
7
- data.tar.gz: 00c1fb99e8891cf6fb4081c42d03ff00b2f6e511350c630529d7255735b353156e9f50cdef5a9e6c2c3018e0032430685a317afbd0d3a33a5b11be0ee643509e
6
+ metadata.gz: 96a55247900e09af2ac195a5819467756cd9bccb302215399d7cc4e8d8d09d01cdb338c04a8e6e45a907b9ad7ca63c209d1696e5f1e7acddf9fa2fe86eefe120
7
+ data.tar.gz: a2c82c78dc036fce298794963999d5327dab6b98d23f6eb778b79dd532dac2a5003065af0fd7fa44c4f188a52dd83ee15bbea6096d3f6c4ce4051ada60c08326
data/README.md CHANGED
@@ -93,13 +93,13 @@ Adder.call(num_a: 2, num_b: 3) => 5
93
93
 
94
94
  ```
95
95
 
96
- ## Legacy API
96
+ ## Legacy Arguments API
97
97
 
98
98
  Alternatively you can a legacy API without hash arguments and default values:
99
99
 
100
100
  ```ruby
101
101
  class Calculator < SmartInit::Base
102
- initialize_with_v1 :data
102
+ initialize_with_args :data
103
103
  is_callable
104
104
 
105
105
  def call
@@ -5,7 +5,7 @@ module SmartInit
5
5
  end
6
6
  end
7
7
 
8
- def initialize_with *attributes
8
+ def initialize_with_hash *attributes
9
9
  required_attrs = attributes.select { |attr| attr.is_a?(Symbol) }
10
10
  default_value_attrs = attributes.select { |attr| attr.is_a?(Hash) }.first || {}
11
11
 
@@ -33,7 +33,9 @@ module SmartInit
33
33
  end
34
34
  end
35
35
 
36
- def initialize_with_v1 *attributes
36
+ alias initialize_with initialize_with_hash
37
+
38
+ def initialize_with_args *attributes
37
39
  define_method :initialize do |*parameters|
38
40
  if attributes.count != parameters.count
39
41
  raise ArgumentError, "wrong number of arguments (given #{parameters.count}, expected #{attributes.count})"
@@ -1,3 +1,3 @@
1
1
  module SmartInit
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -3,7 +3,7 @@ require_relative '../lib/smart_init/main'
3
3
 
4
4
  class TestClass
5
5
  extend SmartInit
6
- initialize_with_v1 :attribute_1, :attribute_2
6
+ initialize_with_args :attribute_1, :attribute_2
7
7
  is_callable
8
8
 
9
9
  def call
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_init
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
@@ -55,8 +55,8 @@ files:
55
55
  - lib/smart_init/main.rb
56
56
  - lib/smart_init/version.rb
57
57
  - smart_init.gemspec
58
- - test/test_api.rb
59
- - test/test_v1_api.rb
58
+ - test/test_args_api.rb
59
+ - test/test_hash_api.rb
60
60
  homepage: http://github.com/pawurb/smart_init
61
61
  licenses:
62
62
  - MIT