Module: Verbalize::Action::ClassMethods

Defined in:
lib/verbalize/action.rb

Instance Method Summary collapse

Instance Method Details

#callObject

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_inputsObject



42
43
44
# File 'lib/verbalize/action.rb', line 42

def default_inputs
  (@defaults || {}).keys
end

#defaultsObject



50
51
52
# File 'lib/verbalize/action.rb', line 50

def defaults
  @defaults
end

#input_is_valid?(input, value) ⇒ Boolean

Returns:

  • (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_validationsObject



54
55
56
# File 'lib/verbalize/action.rb', line 54

def input_validations
  @input_validations ||= {}
end

#inputsObject



46
47
48
# File 'lib/verbalize/action.rb', line 46

def inputs
  required_inputs + optional_inputs + default_inputs
end

#optional_inputsObject



38
39
40
# File 'lib/verbalize/action.rb', line 38

def optional_inputs
  @optional_inputs || []
end

#pop_local_errorObject



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_inputsObject



34
35
36
# File 'lib/verbalize/action.rb', line 34

def required_inputs
  @required_inputs || []
end