substation 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.0.4 2013-05-15
2
+
3
+ * [changed] Bump concord dependency to ~> 0.1.0 (snusnu)
4
+
5
+ * concord generated attribute readers are now `protected` by default
6
+
7
+ [Compare v0.0.3..v0.0.4](https://github.com/snusnu/substation/compare/v0.0.3...v0.0.4)
8
+
1
9
  # v0.0.3 2013-05-15
2
10
 
3
11
  * [changed] Stop (deep) freezing objects coming from client code (snusnu)
@@ -201,7 +201,7 @@ module Substation
201
201
  # config = { :some_use_case => { :action => App::SomeUseCase } }
202
202
  # dispatcher = Substation::Dispatcher.coerce(config, env)
203
203
  #
204
- # response = dispatcher.call(:some_use_case, :some_input, env)
204
+ # response = dispatcher.call(:some_use_case, :some_input)
205
205
  # response.success? # => true
206
206
  #
207
207
  # @param [Symbol] name
@@ -6,6 +6,36 @@ module Substation
6
6
  include Concord.new(:env, :input)
7
7
  include Adamantium::Flat
8
8
 
9
+ # The application environment
10
+ #
11
+ # @example
12
+ #
13
+ # class SomeUseCase
14
+ # def self.call(request)
15
+ # request.env
16
+ # end
17
+ # end
18
+ #
19
+ # @return [Object]
20
+ #
21
+ # @api public
22
+ attr_reader :env
23
+
24
+ # The input passed to an action
25
+ #
26
+ # @example
27
+ #
28
+ # class SomeUseCase
29
+ # def self.call(request)
30
+ # request.input
31
+ # end
32
+ # end
33
+ #
34
+ # @return [Object]
35
+ #
36
+ # @api public
37
+ attr_reader :input
38
+
9
39
  # Create a new successful response
10
40
  #
11
41
  # @example
@@ -2,6 +2,38 @@ module Substation
2
2
 
3
3
  # Base class for action responses
4
4
  #
5
+ # The following code illustrates context and serves as setup for all
6
+ # instance method doc examples
7
+ #
8
+ # module App
9
+ # class Environment
10
+ # def initialize(storage, logger)
11
+ # @storage, @logger = storage, logger
12
+ # end
13
+ # end
14
+ #
15
+ # class SuccessfulAction
16
+ # def self.call(request)
17
+ # data = perform_work
18
+ # request.success(data)
19
+ # end
20
+ # end
21
+ #
22
+ # class FailingAction
23
+ # def self.call(request)
24
+ # error = perform_work
25
+ # request.error(error)
26
+ # end
27
+ # end
28
+ # end
29
+ #
30
+ # storage = SomeStorageAbstraction.new
31
+ # env = App::Environment.new(storage, Logger.new($stdout))
32
+ # dispatcher = Substation::Dispatcher.coerce({
33
+ # :successful_action => { :action => App::SuccessfulAction },
34
+ # :failing_action => { :action => App::FailingAction }
35
+ # }, env)
36
+ #
5
37
  # @abstract
6
38
  class Response
7
39
 
@@ -9,30 +41,24 @@ module Substation
9
41
  include Equalizer.new(:request, :output)
10
42
  include Adamantium::Flat
11
43
 
12
- # The environment used to return this response
44
+ # The application environment used within an action
13
45
  #
14
- # @return [Environment]
46
+ # @example
15
47
  #
16
- # @api private
48
+ # response = dispatcher.call(:successful_action, :some_input)
49
+ # response.env # => env passed to Substation::Dispatcher.coerce(config, env)
50
+ #
51
+ # @return [Object]
52
+ #
53
+ # @api public
17
54
  attr_reader :env
18
55
 
19
56
  # The request model instance passed into an action
20
57
  #
21
58
  # @example
22
59
  #
23
- # class SomeUseCase
24
- # def self.call(request)
25
- # data = perform_work
26
- # request.success(data)
27
- # end
28
- # end
29
- #
30
- # env = Substation::Environment.coerce({
31
- # 'some_use_case' => { 'action' => 'SomeUseCase' }
32
- # })
33
- #
34
- # response = env.dispatch(:some_use_case, :input)
35
- # response.input # => :input
60
+ # response = dispatcher.call(:successful_action, :some_input)
61
+ # response.input # => :some_input
36
62
  #
37
63
  # @see Request#input
38
64
  #
@@ -45,18 +71,8 @@ module Substation
45
71
  #
46
72
  # @example
47
73
  #
48
- # class SomeUseCase
49
- # def self.call(request)
50
- # request.success(:output)
51
- # end
52
- # end
53
- #
54
- # env = Substation::Environment.coerce({
55
- # 'some_use_case' => { 'action' => 'SomeUseCase' }
56
- # })
57
- #
58
- # response = env.dispatch(:some_use_case, :input)
59
- # response.output # => :output
74
+ # response = dispatcher.call(:successful_action, :some_input)
75
+ # response.output # => data passed to request.success(data)
60
76
  #
61
77
  # @return [Object]
62
78
  #
@@ -90,18 +106,7 @@ module Substation
90
106
  #
91
107
  # @example
92
108
  #
93
- # class SomeUseCase
94
- # def self.call(request)
95
- # request.success(:data)
96
- # end
97
- # end
98
- #
99
- # env = Substation::Environment.coerce({
100
- # 'some_use_case' => { 'action' => 'SomeUseCase' }
101
- # })
102
- #
103
- # response = env.dispatch(:some_use_case, :input)
104
- # response.class # Substation::Response::Success
109
+ # response = dispatcher.call(:successful_action, :some_input)
105
110
  # response.success? # => true
106
111
  #
107
112
  # @return [Boolean]
@@ -126,17 +131,7 @@ module Substation
126
131
  #
127
132
  # @example
128
133
  #
129
- # class SomeUseCase
130
- # def self.call(request)
131
- # request.error(:output)
132
- # end
133
- # end
134
- #
135
- # env = Substation::Environment.coerce({
136
- # 'some_use_case' => { 'action' => 'SomeUseCase' }
137
- # })
138
- #
139
- # response = env.dispatch(:some_use_case, :input)
134
+ # response = dispatcher.call(:failing_action, :some_input)
140
135
  # response.success? # => false
141
136
  #
142
137
  # @return [false]
@@ -154,17 +149,7 @@ module Substation
154
149
  #
155
150
  # @example
156
151
  #
157
- # class SomeUseCase
158
- # def self.call(request)
159
- # request.success(:data)
160
- # end
161
- # end
162
- #
163
- # env = Substation::Environment.coerce({
164
- # 'some_use_case' => { 'action' => 'SomeUseCase' }
165
- # })
166
- #
167
- # response = env.dispatch(:some_use_case, :input)
152
+ # response = dispatcher.call(:successful_action, :some_input)
168
153
  # response.success? # => true
169
154
  #
170
155
  # @return [true]
@@ -1,4 +1,4 @@
1
1
  module Substation
2
2
  # Gem version
3
- VERSION = '0.0.3'.freeze
3
+ VERSION = '0.0.4'.freeze
4
4
  end
data/substation.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency 'adamantium', '~> 0.0.7'
20
20
  gem.add_dependency 'equalizer', '~> 0.0.5'
21
21
  gem.add_dependency 'abstract_type', '~> 0.0.5'
22
- gem.add_dependency 'concord', '~> 0.0.3'
22
+ gem.add_dependency 'concord', '~> 0.1.0'
23
23
 
24
24
  gem.add_development_dependency 'bundler', '~> 1.3.5'
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: substation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 0.0.3
69
+ version: 0.1.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 0.0.3
77
+ version: 0.1.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bundler
80
80
  requirement: !ruby/object:Gem::Requirement