Module: UseCase
- Defined in:
- lib/use_case/outcome.rb,
lib/use_case.rb,
lib/use_case/version.rb,
lib/use_case/validator.rb
Overview
– The MIT License (MIT)
Copyright © 2013 Gitorious AS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++
Defined Under Namespace
Modules: Validator Classes: FailedOutcome, Outcome, PreConditionFailed, PreConditionFailure, SuccessfulOutcome
Constant Summary collapse
- VERSION =
"0.13.0"
Instance Method Summary collapse
- #add_pre_condition(pc) ⇒ Object
- #execute(params = {}) ⇒ Object
- #input_class(input_class) ⇒ Object
- #step(command, options = {}) ⇒ Object
Instance Method Details
#add_pre_condition(pc) ⇒ Object
34 35 36 |
# File 'lib/use_case.rb', line 34 def add_pre_condition(pc) pre_conditions << pc end |
#execute(params = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/use_case.rb', line 47 def execute(params = {}) input = @input_class && @input_class.new(params) || params if outcome = verify_pre_conditions(input) return outcome end execute_steps(@steps, input) end |
#input_class(input_class) ⇒ Object
30 31 32 |
# File 'lib/use_case.rb', line 30 def input_class(input_class) @input_class = input_class end |
#step(command, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/use_case.rb', line 38 def step(command, = {}) @steps ||= [] @steps << { :command => command, :builder => [:builder], :validators => Array([:validators] || [:validator]) } end |