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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/callee.rb +16 -5
- data/lib/callee/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4994d32a49e23ce76d18e6e9dfd87566b3ad70be1b1159e8d8a7363674e193fb
|
4
|
+
data.tar.gz: 8e639218eca652fc3f8404d0e0a7ccba9e19ba265c7511bf9ec5130bbd8072fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55c8ebaea344b413666c6e19857b40a1119c143f19ff35182bf0efd6cbcc058f0f01ba042f76545b436e0dadf9a0623f3ea0648fe52becb05308e8046295def8
|
7
|
+
data.tar.gz: 7c6bf4836fd000a1588cccf0596a65c746acf609e525195f8efd51d8c90c701ce22304939cc0c9fb0a6c338e46eda034e258b628a5bb0290b65215351988813c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -97,8 +97,8 @@ end
|
|
97
97
|
|
98
98
|
string_values = %w[1 2 3]
|
99
99
|
|
100
|
-
|
101
|
-
|
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.
|
data/lib/callee.rb
CHANGED
@@ -2,19 +2,30 @@ require "dry-initializer"
|
|
2
2
|
require "callee/version"
|
3
3
|
|
4
4
|
module Callee
|
5
|
-
def self.included(
|
6
|
-
|
7
|
-
|
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(*
|
12
|
-
|
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
|
data/lib/callee/version.rb
CHANGED
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.
|
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
|
11
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-initializer
|