restpack_service 0.0.75 → 0.0.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restpack_service/command.rb +0 -18
- data/lib/restpack_service/version.rb +1 -1
- data/spec/command_spec.rb +0 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff9a4eae5f0590fb89b11f07e85f15037562e17
|
4
|
+
data.tar.gz: 8d10e8416c9ff99efadaaa3fd27f76fe9467ecab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c23efcc038018461512c2cf46c2ef25b1fdd2141694859b9723eaa995f44f14f934edbbd2b395bf8f748ea815ba10027f5b7e9fa01f224fc31c63afcdf61cd
|
7
|
+
data.tar.gz: 43b4271e9ee8395a3d24584e0679a5e35a012611dbf0b791dcc2a9ffddb9319efaef7926d6c5205cee87f0e2ce596161d476e9afa7a4065e0902d2529a3f6d8e
|
@@ -68,7 +68,6 @@ module RestPack::Service
|
|
68
68
|
namespaces = command.to_s.split('::') # eg. GroupService::Commands::Group::Create
|
69
69
|
|
70
70
|
add_module_aliases(command, namespaces)
|
71
|
-
add_command_methods(command, namespaces)
|
72
71
|
end
|
73
72
|
|
74
73
|
private
|
@@ -85,23 +84,6 @@ module RestPack::Service
|
|
85
84
|
command.const_set(:Models, "#{namespaces[0]}::Models".safe_constantize)
|
86
85
|
end
|
87
86
|
|
88
|
-
def self.add_command_methods(command, namespaces)
|
89
|
-
method_name = command.name.demodulize.downcase
|
90
|
-
container = method_container_module(command, namespaces)
|
91
|
-
|
92
|
-
container.send(
|
93
|
-
:define_singleton_method,
|
94
|
-
method_name.to_sym,
|
95
|
-
Proc.new { |*args| command.run(*args) }
|
96
|
-
)
|
97
|
-
|
98
|
-
container.send(
|
99
|
-
:define_singleton_method,
|
100
|
-
"#{method_name}!".to_sym,
|
101
|
-
Proc.new { |*args| command.run!(*args) }
|
102
|
-
)
|
103
|
-
end
|
104
|
-
|
105
87
|
def self.method_container_module(command, namespaces)
|
106
88
|
if namespaces[1] == 'Commands'
|
107
89
|
"#{namespaces[0]}::#{namespaces[2]}".safe_constantize #GroupService::Group
|
data/spec/command_spec.rb
CHANGED
@@ -2,11 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe RestPack::Service::Command do
|
4
4
|
context 'with a commands in a namespace like TextService::Commands::Text::Reverse' do
|
5
|
-
it 'defines sugar methods' do
|
6
|
-
expect(TextService::Text).to respond_to(:reverse, :reverse!)
|
7
|
-
expect(TextService::Text.reverse!(text: 'gavin')).to eq('nivag')
|
8
|
-
end
|
9
|
-
|
10
5
|
it 'defines aliases' do
|
11
6
|
Command = TextService::Commands::Text::Reverse
|
12
7
|
command = Command.new
|
@@ -21,11 +16,4 @@ describe RestPack::Service::Command do
|
|
21
16
|
expect(Command::Models).to eq(TextService::Models)
|
22
17
|
end
|
23
18
|
end
|
24
|
-
|
25
|
-
context 'with a commands in a namespace like Commands::Template::Create' do
|
26
|
-
it 'defines sugar methods' do
|
27
|
-
expect(Commands::Math).to respond_to(:add, :add!)
|
28
|
-
expect(Commands::Math.add!(a: 1, b: 2)).to eq(3)
|
29
|
-
end
|
30
|
-
end
|
31
19
|
end
|