Module: Verbalize::Action::ClassMethods
- Defined in:
- lib/verbalize/action.rb
Instance Method Summary collapse
-
#call ⇒ Object
Because call/call! are defined when Action.input is called, they would not be defined when there is no input.
- #call! ⇒ Object (also: #!)
- #default_inputs ⇒ Object
- #defaults ⇒ Object
- #input_is_valid?(input, value) ⇒ Boolean
- #input_validations ⇒ Object
- #inputs ⇒ Object
- #optional_inputs ⇒ Object
- #pop_local_error ⇒ Object
- #required_inputs ⇒ Object
Instance Method Details
#call ⇒ Object
Because call/call! are defined when Action.input is called, they would not be defined when there is no input. So we pre-define them here, and if there is any input, they are overwritten
77 78 79 |
# File 'lib/verbalize/action.rb', line 77 def call __proxied_call end |
#call! ⇒ Object Also known as: !
81 82 83 |
# File 'lib/verbalize/action.rb', line 81 def call! __proxied_call! end |
#default_inputs ⇒ Object
42 43 44 |
# File 'lib/verbalize/action.rb', line 42 def default_inputs (@defaults || {}).keys end |
#defaults ⇒ Object
50 51 52 |
# File 'lib/verbalize/action.rb', line 50 def defaults @defaults end |
#input_is_valid?(input, value) ⇒ Boolean
58 59 60 61 62 63 64 65 |
# File 'lib/verbalize/action.rb', line 58 def input_is_valid?(input, value) return true unless input_validations.include?(input.to_sym) input_validations[input].call(value) == true rescue => e @local_error = e false end |
#input_validations ⇒ Object
54 55 56 |
# File 'lib/verbalize/action.rb', line 54 def input_validations @input_validations ||= {} end |
#inputs ⇒ Object
46 47 48 |
# File 'lib/verbalize/action.rb', line 46 def inputs required_inputs + optional_inputs + default_inputs end |
#optional_inputs ⇒ Object
38 39 40 |
# File 'lib/verbalize/action.rb', line 38 def optional_inputs @optional_inputs || [] end |
#pop_local_error ⇒ Object
67 68 69 70 71 72 |
# File 'lib/verbalize/action.rb', line 67 def pop_local_error return nil unless @local_error @local_error ensure @local_error = nil end |
#required_inputs ⇒ Object
34 35 36 |
# File 'lib/verbalize/action.rb', line 34 def required_inputs @required_inputs || [] end |