callee 0.1.3 → 0.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: 1bf8daea867adfaeae359d3ed4746d574faa7de26e3b5d95ceaae75c76b756c3
4
- data.tar.gz: 3d88629682457b5b9fe3d2181f2cefce839ff75ef62afac0365810ff20b2d622
3
+ metadata.gz: 4994d32a49e23ce76d18e6e9dfd87566b3ad70be1b1159e8d8a7363674e193fb
4
+ data.tar.gz: 8e639218eca652fc3f8404d0e0a7ccba9e19ba265c7511bf9ec5130bbd8072fc
5
5
  SHA512:
6
- metadata.gz: 676dfa2bbfe6e4460e262deaece0350d4fbd52b4ae5bd62546104322cc4002c6c5ce85146f994ea86ebde1b75b7b2fb18400186e163a7ad419f5a9b56070d863
7
- data.tar.gz: 90a7d51b3b9fb35d342a7b64257d001fc985c6820c4b5a8b28bd27fd46b26cdaef571ca961a094bfb32c16c6774234530dce14e7d03f11c39224e8e178d8aacb
6
+ metadata.gz: 55c8ebaea344b413666c6e19857b40a1119c143f19ff35182bf0efd6cbcc058f0f01ba042f76545b436e0dadf9a0623f3ea0648fe52becb05308e8046295def8
7
+ data.tar.gz: 7c6bf4836fd000a1588cccf0596a65c746acf609e525195f8efd51d8c90c701ce22304939cc0c9fb0a6c338e46eda034e258b628a5bb0290b65215351988813c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- callee (0.1.3)
4
+ callee (0.2.0)
5
5
  dry-initializer (>= 2.5, < 4.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -97,8 +97,8 @@ end
97
97
 
98
98
  string_values = %w[1 2 3]
99
99
 
100
- pp string_values.map(&StrictPower) # Will raise Dry::Types::ConstraintError
101
- pp string_values.map(&CoerciblePower) # => [1, 4, 9]
100
+ string_values.map(&StrictPower) # Will raise Dry::Types::ConstraintError
101
+ string_values.map(&CoerciblePower) # => [1, 4, 9]
102
102
  ```
103
103
 
104
104
  See [more examples](https://dry-rb.org/gems/dry-initializer/type-constraints/) in dry-rb docs.
@@ -2,19 +2,30 @@ require "dry-initializer"
2
2
  require "callee/version"
3
3
 
4
4
  module Callee
5
- def self.included(base)
6
- base.extend(Dry::Initializer)
7
- base.extend(ClassMethods)
5
+ def self.included(other)
6
+ other.extend(Dry::Initializer)
7
+ other.extend(ClassMethods)
8
8
  end
9
9
 
10
10
  module ClassMethods
11
- def call(*args, **kwargs)
12
- new(*args, **kwargs).call
11
+ def call(*params, **options)
12
+ create_callable(params, options).call
13
13
  end
14
14
 
15
15
  def to_proc
16
16
  method(:call).to_proc
17
17
  end
18
+
19
+ private
20
+
21
+ def create_callable(params, options)
22
+ has_params = params.any?
23
+ has_options = options.any?
24
+ return new unless has_params || has_options
25
+ return new(*params) unless has_options
26
+ return new(**options) unless has_params
27
+ new(*params, **options)
28
+ end
18
29
  end
19
30
 
20
31
  def call
@@ -1,3 +1,3 @@
1
1
  module Callee
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Musayev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-29 00:00:00.000000000 Z
11
+ date: 2019-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer