use_case 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/use_case.rb +2 -2
- data/lib/use_case/outcome.rb +5 -2
- data/lib/use_case/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/use_case.rb
CHANGED
@@ -44,7 +44,7 @@ module UseCase
|
|
44
44
|
}
|
45
45
|
end
|
46
46
|
|
47
|
-
def execute(params)
|
47
|
+
def execute(params = {})
|
48
48
|
input = @input_class && @input_class.new(params) || params
|
49
49
|
|
50
50
|
if outcome = verify_pre_conditions(input)
|
@@ -98,7 +98,7 @@ module UseCase
|
|
98
98
|
def validate_params(input, validators)
|
99
99
|
validators.each do |validator|
|
100
100
|
result = validator.call(input)
|
101
|
-
return FailedOutcome.new(self, result) if !result.valid?
|
101
|
+
return FailedOutcome.new(self, result, input) if !result.valid?
|
102
102
|
end
|
103
103
|
nil
|
104
104
|
end
|
data/lib/use_case/outcome.rb
CHANGED
@@ -104,13 +104,16 @@ module UseCase
|
|
104
104
|
end
|
105
105
|
|
106
106
|
class FailedOutcome < Outcome
|
107
|
-
|
107
|
+
attr_reader :input
|
108
|
+
|
109
|
+
def initialize(use_case = nil, errors = nil, input = nil)
|
108
110
|
super(use_case)
|
109
111
|
@errors = errors
|
112
|
+
@input = input
|
110
113
|
end
|
111
114
|
|
112
115
|
def failure
|
113
|
-
yield @errors if block_given?
|
116
|
+
yield @errors, @input if block_given?
|
114
117
|
@errors
|
115
118
|
end
|
116
119
|
|
data/lib/use_case/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: use_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|