Class: Subroutine::Op
- Inherits:
-
Object
- Object
- Subroutine::Op
- Defined in:
- lib/subroutine/op.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(inputs = {}) {|_self| ... } ⇒ Op
constructor
A new instance of Op.
-
#submit ⇒ Object
the action which should be invoked upon form submission (from the controller).
- #submit! ⇒ Object
Methods included from Outputs
#get_output, #output, #output_provided?, #setup_outputs, #validate_outputs!
Methods included from Fields
action_controller_params_loaded?, #all_default_params, #all_params, #all_params_with_defaults, allowed_input_classes, #clear_field, #field_provided?, #fields_in_group, #get_field, #get_field_config, #get_param_group, #original_params, #param_groups, #set_field, #setup_fields, #ungrouped_defaults, #ungrouped_fields, #ungrouped_params, #ungrouped_params_with_defaults
Constructor Details
#initialize(inputs = {}) {|_self| ... } ⇒ Op
Returns a new instance of Op.
62 63 64 65 66 |
# File 'lib/subroutine/op.rb', line 62 def initialize(inputs = {}) setup_fields(inputs) setup_outputs yield self if block_given? end |
Class Method Details
.failure_class(klass) ⇒ Object
19 20 21 |
# File 'lib/subroutine/op.rb', line 19 def failure_class(klass) self._failure_class = klass end |
.submit(*args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/subroutine/op.rb', line 32 def submit(*args) raise ArgumentError, "Blocks cannot be provided to `submit`." if block_given? op = new(*args) op.submit op end |
.submit!(*args) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/subroutine/op.rb', line 23 def submit!(*args) raise ArgumentError, "Blocks cannot be provided to `submit!`" if block_given? op = new(*args) op.submit! op end |
Instance Method Details
#submit ⇒ Object
the action which should be invoked upon form submission (from the controller)
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/subroutine/op.rb', line 92 def submit submit! rescue Exception => e if e.respond_to?(:record) inherit_errors(e.record) unless e.record == self false else raise end end |
#submit! ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/subroutine/op.rb', line 68 def submit! begin observe_submission do validate_and_perform end rescue Exception => e if e.respond_to?(:record) inherit_errors(e.record) unless e.record == self new_e = _failure_class.new(self) raise new_e, new_e., e.backtrace else raise end end if errors.empty? validate_outputs! true else raise _failure_class, self end end |