Module: Wicked::Wizard::Validations

Extended by:
ActiveSupport::Concern
Defined in:
lib/wicked/wizard/validations.rb,
lib/wicked/wizard/validations/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Instance Method Details

#current_and_previous_wizard_stepsObject

 @return [Array] an ordered list of wizard steps, up to and including this one



104
105
106
# File 'lib/wicked/wizard/validations.rb', line 104

def current_and_previous_wizard_steps
  previous_wizard_steps.push(current_wizard_step.to_sym)
end

#current_wizard_stepObject

Get the current wizard step by calling the instance method specified in the class; fall back to calling ‘current_step` on the instance.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/wicked/wizard/validations.rb', line 82

def current_wizard_step
  meth = self.class.current_step_method
  if meth.present?
    case meth.class.to_s
      when "Symbol"
        self.send(meth)
      else
        raise ArgumentError, "current_step_method accepts a symbol, which should be the name of a callable instance method"
    end
  else
    #assume the method is called current_step() and call that
    current_step
  end
end

#previous_wizard_stepsArray

Call the ‘previous_wizard_steps` class method, passing in the current step for this instance

Returns:

  • (Array)

    an ordered list of wizard steps which happen before the current one



99
100
101
# File 'lib/wicked/wizard/validations.rb', line 99

def previous_wizard_steps
  self.class.previous_wizard_steps(current_wizard_step.to_sym)
end