actionizer 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e42fbee7c17ec92f6707be99f052aa53a636608c
4
- data.tar.gz: 0eb62083452a04663b8698174ed63e0a10d134fb
3
+ metadata.gz: f469641ab666e35726b4d5947291460f7ee19d4e
4
+ data.tar.gz: a502b47502c021c1d6a727c5a88dea62426d0d1e
5
5
  SHA512:
6
- metadata.gz: 6acb97664962b2713a995e2d41601539b064a9629683951e0fce5e9bdad1e233946dafdb6d307019a912b5afa4c8cbc3b6a294f15f988ad986558d5c53b97d72
7
- data.tar.gz: e61bf0c0d94e76885ff20bba84ae1d56d8ee3715f22a3d1442c5940ac27d6621afc69bda621adb9d3ae9f9c9d19c7d4758c117f8929c343bed04e370f8999499
6
+ metadata.gz: aa6f99b81e8a95dcb0d58dc02befc7442ffd930c0ff5d119c8b92ec9d91b713da3e972f421443ce8db27f8cbdda3932c2d27d3be2b980b86f71f9d5622581291
7
+ data.tar.gz: 84ac0753c80f7759acf0281cd9c9d024058a7d7787c5ddbcb705f4998887c26f020637c7822835792bc7d2942fe28a39c061f5546f99720bafaaa3ec2de73859
data/.rubocop.yml CHANGED
@@ -14,12 +14,15 @@ Metrics/MethodLength:
14
14
 
15
15
  Style/Documentation:
16
16
  Enabled: false
17
+
17
18
  Style/EmptyLinesAroundBlockBody:
18
19
  Enabled: false
19
20
  Style/EmptyLinesAroundClassBody:
20
21
  Enabled: false
21
22
  Style/FrozenStringLiteralComment:
22
23
  Enabled: false
24
+ Style/IfUnlessModifier:
25
+ Enabled: false
23
26
  Style/MutableConstant:
24
27
  Enabled: false
25
28
  Style/NegatedIf:
data/README.md CHANGED
@@ -139,7 +139,7 @@ To more explicitly document the inputs to your Actions, you can use `inputs_for`
139
139
  class CreateUser
140
140
  include Actionizer
141
141
 
142
- inputs_for :call do
142
+ inputs_for(:call) do
143
143
  required :name
144
144
  required :email
145
145
  optional :phone_number
@@ -156,7 +156,27 @@ class CreateUser
156
156
  end
157
157
  ```
158
158
 
159
- You'll get an `ArgumentError` if you pass any params not defined in the `inputs_for` block, or if you don't supply all required params. This is completely opt-in so if you don't provide an `inputs_for` block, no checking is performed.
159
+ ### Specifying types and nullable fields
160
+
161
+ You can now also optionally specify types and nullability for your inputs. For the `type:` option, any ruby class can be used.
162
+
163
+ ```ruby
164
+ inputs_for(:call) do
165
+ required :name, type: String, null: false
166
+ required :email, null: false
167
+ optional :phone_number, type: Integer
168
+ end
169
+ ```
170
+
171
+ ### `inputs_for` error handling
172
+
173
+ The action will fail immediately if any of the conditions are met:
174
+ - Any required param is not passed
175
+ - A param is passed that is not declared
176
+ - `nil` is passed for a param marked `null: false` (default is `null: true`)
177
+ - The class of the argument is not equal to or a subclass of the specified type
178
+
179
+ Using an `inputs_for` block is completely opt-in so if you don't provide it, no checking is performed.
160
180
 
161
181
  ## Development
162
182
 
data/actionizer.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'rake', '~> 11.3'
33
33
  spec.add_development_dependency 'rspec', '~> 3.5'
34
34
  spec.add_development_dependency 'pry-byebug', '~> 3.4'
35
- spec.add_development_dependency 'rubocop', '~> 0.45'
35
+ spec.add_development_dependency 'rubocop', '0.45.0'
36
36
  spec.add_development_dependency 'simplecov', '~> 0.12'
37
37
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.5'
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module Actionizer
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
data/lib/actionizer.rb CHANGED
@@ -17,7 +17,9 @@ module Actionizer
17
17
 
18
18
  if instance.respond_to?(method_name)
19
19
  error = defined_inputs.check_for_param_error(method_name, *args)
20
- raise ArgumentError, error if error
20
+ if error
21
+ return Actionizer::Result.new(error: error).tap(&:fail)
22
+ end
21
23
 
22
24
  instance.tap(&method_name).output
23
25
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nichols
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0.45'
75
+ version: 0.45.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0.45'
82
+ version: 0.45.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement