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.
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- use_case (0.8.0)
15
+ use_case (0.9.1)
16
16
 
17
17
  GEM
18
18
  remote: http://rubygems.org/
@@ -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
@@ -104,13 +104,16 @@ module UseCase
104
104
  end
105
105
 
106
106
  class FailedOutcome < Outcome
107
- def initialize(use_case = nil, errors = nil)
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
 
@@ -24,5 +24,5 @@
24
24
  #++
25
25
 
26
26
  module UseCase
27
- VERSION = "0.8.0"
27
+ VERSION = "0.9.1"
28
28
  end
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.8.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-07 00:00:00.000000000 Z
12
+ date: 2013-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest