kouba 0.1.1 → 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/README.md +1 -1
- data/lib/kouba/simple_factory.rb +6 -3
- data/lib/kouba/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9005ed77d8d3d91487f4b17a124e87ff4b74d486a28a9fc9e5f08202710dc019
|
4
|
+
data.tar.gz: 7d903b55e4f6f382a16b596a0d1c967d5429bd6ab79a71438bc945531b32a3fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6385d7d556478d32de68d12b3ccfe3a1bce2e10600370aef76fb3feb18757fd5048f281af1e82cf0b1899373b6aed49276d7a66bb3eef0f46ac4413671fae0a6
|
7
|
+
data.tar.gz: 75812e3e464d1610f9b99d5f851a454dc8f895f7551f91a74d6312d78f453c50199b562e6a0e36ecce8f8f336902395f5b45c1cc156aff7098f2e4489abf9a47
|
data/README.md
CHANGED
data/lib/kouba/simple_factory.rb
CHANGED
@@ -3,8 +3,11 @@ require "dry/inflector"
|
|
3
3
|
module Kouba
|
4
4
|
module SimpleFactory
|
5
5
|
def self.included(mod)
|
6
|
-
mod.send(:module_function, :create)
|
7
|
-
|
6
|
+
mod.send(:module_function, :create, :find, :name_key)
|
7
|
+
end
|
8
|
+
|
9
|
+
def name_key(key)
|
10
|
+
@name_key = key
|
8
11
|
end
|
9
12
|
|
10
13
|
def find(name)
|
@@ -16,7 +19,7 @@ module Kouba
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def create(config)
|
19
|
-
(find(config[:name])).new(config[:options])
|
22
|
+
(find(config[@name_key ? @name_key.to_sym : :name])).new(config[:options])
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
data/lib/kouba/version.rb
CHANGED