Module: Stepper::ActiveRecordAdditions::InstanceMethods
- Defined in:
- lib/stepper/models/active_record_additions.rb
Instance Method Summary collapse
-
#first_step?(step = stepper_current_step) ⇒ Boolean
Use to check current step or given step is first step first_step?(“address”).
-
#last_step?(step = stepper_current_step) ⇒ Boolean
Use to check current step or given step is last step last_step?(“address”).
-
#next_step ⇒ Object
returns next step of current step.
-
#next_step! ⇒ Object
set next step as current step.
-
#previous_step ⇒ Object
returns previous step of current step.
-
#previous_step! ⇒ Object
set previous step as current step.
-
#stepper_current_step ⇒ Object
returns name of current step.
-
#stepper_current_step=(step) ⇒ Object
sets up name of current step.
-
#stepper_current_step_index ⇒ Object
returns index of current step in steps array.
- #stepper_steps ⇒ Object
Instance Method Details
#first_step?(step = stepper_current_step) ⇒ Boolean
Use to check current step or given step is first step
first_step?("address")
90 91 92 |
# File 'lib/stepper/models/active_record_additions.rb', line 90 def first_step?(step = stepper_current_step) (step == stepper_steps.first) or stepper_current_step.blank? && step.blank? end |
#last_step?(step = stepper_current_step) ⇒ Boolean
Use to check current step or given step is last step
last_step?("address")
84 85 86 |
# File 'lib/stepper/models/active_record_additions.rb', line 84 def last_step?(step = stepper_current_step) step == self.stepper_steps.last end |
#next_step ⇒ Object
returns next step of current step
107 108 109 110 111 |
# File 'lib/stepper/models/active_record_additions.rb', line 107 def next_step return stepper_steps.first if self.stepper_current_step.blank? return nil if self.last_step? stepper_steps[stepper_steps.index(stepper_current_step) + 1] end |
#next_step! ⇒ Object
set next step as current step
114 115 116 117 |
# File 'lib/stepper/models/active_record_additions.rb', line 114 def next_step! self.stepper_current_step = self.next_step self end |
#previous_step ⇒ Object
returns previous step of current step
95 96 97 98 |
# File 'lib/stepper/models/active_record_additions.rb', line 95 def previous_step return nil if (first_step? or stepper_current_step.blank?) stepper_steps[stepper_steps.index(stepper_current_step) - 1] end |
#previous_step! ⇒ Object
set previous step as current step
101 102 103 104 |
# File 'lib/stepper/models/active_record_additions.rb', line 101 def previous_step! self.stepper_current_step = self.previous_step self end |
#stepper_current_step ⇒ Object
returns name of current step
73 74 75 |
# File 'lib/stepper/models/active_record_additions.rb', line 73 def stepper_current_step self.send(self.stepper_current_step_column) end |
#stepper_current_step=(step) ⇒ Object
sets up name of current step
78 79 80 |
# File 'lib/stepper/models/active_record_additions.rb', line 78 def stepper_current_step=(step) self.send("#{self.stepper_current_step_column.to_s}=", step) end |
#stepper_current_step_index ⇒ Object
returns index of current step in steps array
68 69 70 |
# File 'lib/stepper/models/active_record_additions.rb', line 68 def stepper_current_step_index stepper_steps.index(stepper_current_step) end |
#stepper_steps ⇒ Object
57 58 59 |
# File 'lib/stepper/models/active_record_additions.rb', line 57 def stepper_steps self.[:steps] end |