smart_init 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: 7394612537ae9d948b6a8e18a6ef14ae60e0cdee
4
- data.tar.gz: fc5bc846777c3495a1ce1ead2fc0e9ee0758dd0a
3
+ metadata.gz: 1446b96b76289a0090e6db9d241ecb6e7b5de6db
4
+ data.tar.gz: 94a722499a830e6c2801672bab387f5398d99572
5
5
  SHA512:
6
- metadata.gz: 5319b8f52c4e52aee3916bf280db7484616a284488f14f4e0a3cd8014b02c858e3f646da81b89fe3ae009f14a6ab2ec2bd273b4fddad3a275b32b52b9e80a4c8
7
- data.tar.gz: 8694b7aebfd30e3750e4be7365f71c4dc34dd954a949a0cd6dd694acc1e843b9696e3ecb5979bd63cecb4d46bb093b8d2206a9a79f63f6dc72272041c9e5c4b5
6
+ metadata.gz: a7d717a769b6ef64d4f40a45de80641c5118f913707abcec203bb715bb455a05aba094984dcafeb08e4d36bfdb87b6274aa88a241f6265fb16ceb23c68a8adfc
7
+ data.tar.gz: 63c1b848ab85ddcf6f3f8e3ad38258771a23e5c163f41530ffcf7378b45ae76b5ded98753d4fedee3a3c33157e31376b678a2083706fe71c207c6949f66c6158
@@ -1,6 +1,4 @@
1
1
  module SmartInit
2
- @@_init_attributes = []
3
-
4
2
  def is_callable
5
3
  define_singleton_method :call do |*parameters|
6
4
  new(*parameters).call
@@ -8,7 +6,6 @@ module SmartInit
8
6
  end
9
7
 
10
8
  def initialize_with *attributes
11
- @_init_attributes = attributes
12
9
  define_method :initialize do |*parameters|
13
10
  if attributes.count != parameters.count
14
11
  raise ArgumentError, "wrong number of arguments (given #{parameters.count}, expected #{attributes.count})"
@@ -1,3 +1,3 @@
1
1
  module SmartInit
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -11,6 +11,15 @@ class TestClass
11
11
  end
12
12
  end
13
13
 
14
+ class TestNoInit
15
+ extend SmartInit
16
+ is_callable
17
+
18
+ def call
19
+ 'result'
20
+ end
21
+ end
22
+
14
23
  class SmartInitTest < Test::Unit::TestCase
15
24
  def test_number_of_attributes
16
25
  assert_nothing_raised do
@@ -43,6 +52,10 @@ class SmartInitTest < Test::Unit::TestCase
43
52
  assert_equal TestClass.call("a", "b"), ["a", "b"]
44
53
  end
45
54
 
55
+ def test_is_callable_no_initializers
56
+ assert_equal TestNoInit.call, 'result'
57
+ end
58
+
46
59
  private
47
60
 
48
61
  def test_object
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: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb