responsive_service 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: d201035ae2b1931491a0cdefb73867927a105026
4
- data.tar.gz: e18b6ce1c12afc5b857985d6d172837970d57d56
3
+ metadata.gz: 5613d9e5f1add88d5b60cbe10659ac1fe968d815
4
+ data.tar.gz: eb8e0e330a4d96a647a7bf72aa5c5146e4e328ba
5
5
  SHA512:
6
- metadata.gz: 4c24e42a63f3fe65f9600afb95b700e261aa301c1a1ca7d6463d880cf348b79fec0f4eaee4bdbbec1d9094ece7471c630bd5b20059d2d7ad85a54d686dd950b8
7
- data.tar.gz: 725f27ea43686a14e3bd3ab6eb9655e595a90b29f605458543b8b7f261ad7b4597d3872b35c49bc29141be431aaaaabd8734712e4ffa12a2b2c9700184e41475
6
+ metadata.gz: 739afba739f4c4beceb23d53e0cb52c8817240503b6d0eea4955a90df32e6e9187328e4830f0ee6c7b5d54efda1418371f3c4138ea1c81cf3d6499eb8d6d9724
7
+ data.tar.gz: 7dcc8dd1aa178e2519ff7c0e9e34dbdd36955b81c1e56f75c1547923a0daaa7874df6c2cecd9df3c1a7a51689e11e9d9beed330bbde720997f216f6e277ebfac
data/README.md CHANGED
@@ -19,30 +19,61 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
 
22
+ ### ResponsiveService
23
+
22
24
  Create a service class, either your own or feel free to subclass from `ResponsiveService::ResponsiveService`.
23
25
 
24
26
  ```ruby
25
27
  class MyService < ResponsiveService::ResponsiveService
26
28
  def call(&block)
27
29
  # do some work
28
- yield ResponsiveService::Responder.new(:success)
30
+ yield ResponsiveService::Response.new(:success)
29
31
  end
30
32
  end
31
33
  ```
32
34
 
33
35
  You must implement a `call` method if you subclass `ResponsiveService::ResponsiveService`.
34
- Your call method should yield with a `ResponsiveService::Responder`.
36
+ Your call method should yield with a `ResponsiveService::Response`.
37
+
38
+ ### Response
39
+
40
+ A `ResponsiveService::Response` can take up to 4 arguments but must at least have the first argument which is the type of the response. In addition it can take a message, a context, and a set of valid states. The message by convention should
41
+ be a string but there are no restrictions. The context can be any object. The valid states should be an array of symbols
42
+ that are the allowed states. An exception will be thrown if initialized with a type of response that is not in the valid states if a set of valid states was specified.
43
+
44
+ ```ruby
45
+ response = Response.new(:success, 'You win!', {an_important_value: 'some value'})
46
+ response.type # :success
47
+ response.message # 'You win!'
48
+ response.context # {an_important_value: 'some value'}
49
+
50
+ response.success { puts 'I succeeded' } # I succeeded
51
+ response.failure { puts 'I failed' } # nil
35
52
 
36
- A `ResponsiveService::Responder` can take up to 3 arguments but must at least have the first argument which is the type of the response. In addition it can take a message and a context. The message by convention should
37
- be a string but there are no restrictions. The context can be any object.
53
+ response = Response.new(:foo, 'FOO!', {}, [:success, :failure])
54
+ # exception => Invalid type of response: foo
55
+
56
+ response = Response.new(:success, '', {}, [:success, :failure])
57
+ response.foo { puts 'Not going to work' }
58
+ # exception => NoMethodError: undefined method `foo'
59
+ ```
60
+
61
+ You can also choose to subclass `ResponsiveService::Response` and define valid states for all instances of that class.
38
62
 
39
63
  ```ruby
40
- responder = Responder.new(:success, 'You win!', {an_important_value: 'some value'})
41
- responder.type # :success
42
- responder.message # 'You win!'
43
- responder.context # {an_important_value: 'some value'}
64
+ class MyResponse < ResponsiveService::Response
65
+ valid_states :success, :failure
66
+ end
67
+
68
+ response = MyResponse.new(:success)
69
+ response.success { puts 'I succeeded' } # I succeeded
70
+ response.failure { puts 'I failed' } # nil
71
+ response.foo { puts 'Not going to work' }
72
+ # exception => NoMethodError: undefined method `foo'
44
73
  ```
45
74
 
75
+ ### Your service API
76
+
46
77
  Your service can now be used as such:
47
78
 
48
79
  ```ruby
@@ -1,3 +1,3 @@
1
1
  module ResponsiveService
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'responsive_service'
8
8
  spec.version = ResponsiveService::VERSION
9
9
  spec.authors = ['alexpeachey']
10
- spec.email = ['alex.peachey@gmail.com']
11
- spec.description = 'Easy to use responsive service pattern'
12
- spec.summary = 'Easy to use responsive service pattern'
13
- spec.homepage = 'http://github.com/alexpeachey/responsive_service'
10
+ spec.email = ['alex.peachey@originate.com']
11
+ spec.description = 'Easy to use response state pattern'
12
+ spec.summary = 'Easy to use response state pattern'
13
+ spec.homepage = 'http://github.com/Originate/response_state'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: responsive_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexpeachey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,9 +66,9 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Easy to use responsive service pattern
69
+ description: Easy to use response state pattern
70
70
  email:
71
- - alex.peachey@gmail.com
71
+ - alex.peachey@originate.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -87,7 +87,7 @@ files:
87
87
  - spec/lib/responsive_service/response_spec.rb
88
88
  - spec/lib/responsive_service/responsive_service_spec.rb
89
89
  - spec/spec_helper.rb
90
- homepage: http://github.com/alexpeachey/responsive_service
90
+ homepage: http://github.com/Originate/response_state
91
91
  licenses:
92
92
  - MIT
93
93
  metadata: {}
@@ -107,10 +107,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.2.1
110
+ rubygems_version: 2.2.2
111
111
  signing_key:
112
112
  specification_version: 4
113
- summary: Easy to use responsive service pattern
113
+ summary: Easy to use response state pattern
114
114
  test_files:
115
115
  - spec/lib/responsive_service/response_spec.rb
116
116
  - spec/lib/responsive_service/responsive_service_spec.rb