interactor-initializer 0.3.1 → 0.4.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: e3ea58c9b012de5b156139019d173263e679ce434a7acd02ff519ddb9a870ff6
4
- data.tar.gz: 819740461e55ae27e97c59babe2ef3030feccb3bf28b0c022ffa627e8b994764
3
+ metadata.gz: 5af4b74086ee54c325a0978227a41cba1449b7369ae4d77d8144cb93e4392a36
4
+ data.tar.gz: cc5551943cffcf530daf69fe18c29bee0fcb46a4c07cb411bb13074a5f74772d
5
5
  SHA512:
6
- metadata.gz: 0c2e0049fa3c92b586fa67c8c0bc6c6199c92207b2b2eb312af4708866e078b86fe0b3ae804be70754f1b726423b21a8f250c273ab04c2f5c93b4513b6163996
7
- data.tar.gz: 711c376811a586fc39f01bcd65cb6c0fde86890585d205dd4e01b9835f01085ad53ffacf3c44c314966ee75e1563e5b443315471b75ea9893d317cbb176284ef
6
+ metadata.gz: f7cf6987a066b3649813d0c38da664c6c6f49aac8541e34055c636e5f182c03c30a3d55987cce42b36c299bc8b49003e92a3a52780e9ea8dec45a7fb9fc2bc9b
7
+ data.tar.gz: 5ee5a3989601d9c70eec1245c1fab592ff78b45aa4a2efe614f5036382bbcf4986e692581dda139470f29ee1d205e8c5f9c29b8be46ea363fdaabed156b9c6f9
@@ -1,16 +1,26 @@
1
1
  require 'interactor/initializer/version'
2
2
  require 'interactor/initializer/attr_readers'
3
- require 'interactor/initializer/call_methods'
4
3
  require 'interactor/initializer/initialize'
5
4
 
6
5
  module Interactor
7
6
  module Initializer
8
7
  def self.included(target_class)
9
8
  target_class.extend ClassMethods
10
- Interactor::Initializer::CallMethods.for(target_class)
11
9
  end
12
10
 
13
11
  module ClassMethods
12
+ def for(*args)
13
+ new(*args).run
14
+ end
15
+
16
+ def with(*args)
17
+ new(*args).run
18
+ end
19
+
20
+ def run(*args)
21
+ new(*args).run
22
+ end
23
+
14
24
  module_function
15
25
 
16
26
  def initialize_with(*attributes)
@@ -1,5 +1,5 @@
1
1
  module Interactor
2
2
  module Initializer
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,29 @@
1
+ describe Interactor::Initializer do
2
+ let(:interactor) do
3
+ Class.new do
4
+ include Interactor::Initializer
5
+
6
+ def run
7
+ :result
8
+ end
9
+ end
10
+ end
11
+
12
+ describe '.for' do
13
+ subject { interactor.for }
14
+
15
+ it { is_expected.to eq(:result) }
16
+ end
17
+
18
+ describe '.with' do
19
+ subject { interactor.with }
20
+
21
+ it { is_expected.to eq(:result) }
22
+ end
23
+
24
+ describe '.run' do
25
+ subject { interactor.run }
26
+
27
+ it { is_expected.to eq(:result) }
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interactor-initializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Šarūnas Kūjalis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,12 +70,11 @@ files:
70
70
  - interactor-initializer.gemspec
71
71
  - lib/interactor/initializer.rb
72
72
  - lib/interactor/initializer/attr_readers.rb
73
- - lib/interactor/initializer/call_methods.rb
74
73
  - lib/interactor/initializer/initialize.rb
75
74
  - lib/interactor/initializer/version.rb
76
- - spec/initializer/attr_readers_spec.rb
77
- - spec/initializer/call_methods_spec.rb
78
- - spec/initializer/initialize_spec.rb
75
+ - spec/interactor/initializer/attr_readers_spec.rb
76
+ - spec/interactor/initializer/initialize_spec.rb
77
+ - spec/interactor/initializer_spec.rb
79
78
  - spec/spec_helper.rb
80
79
  homepage: https://github.com/vinted/interactor-initializer
81
80
  licenses:
@@ -1,9 +0,0 @@
1
- class Interactor::Initializer::CallMethods
2
- METHOD_NAMES = %i(for with run).freeze
3
-
4
- def self.for(target_class)
5
- METHOD_NAMES.each do |method_name|
6
- target_class.define_singleton_method(method_name) { |*args| new(*args).run }
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- describe Interactor::Initializer::CallMethods do
2
- describe '.for' do
3
- subject { described_class.for(dummy_class) }
4
- let(:dummy_class) { Class.new }
5
-
6
- it 'adds .for .with and .run class methods' do
7
- subject
8
- expect(dummy_class).to respond_to :for
9
- expect(dummy_class).to respond_to :with
10
- expect(dummy_class).to respond_to :run
11
- end
12
- end
13
- end