Module: Stepper::ActiveRecordAdditions::InstanceMethods
- Defined in:
- lib/stepper/models/active_record_additions.rb
Instance Method Summary collapse
- #first_step?(step = stepper_current_step) ⇒ Boolean
- #last_step?(step = stepper_current_step) ⇒ Boolean
- #next_step ⇒ Object
- #next_step! ⇒ Object
- #previous_step ⇒ Object
- #previous_step! ⇒ Object
- #stepper_current_step ⇒ Object
- #stepper_current_step=(step) ⇒ Object
- #stepper_current_step_column ⇒ Object
- #stepper_current_step_index ⇒ Object
- #stepper_steps ⇒ Object (also: #steps)
Instance Method Details
#first_step?(step = stepper_current_step) ⇒ Boolean
60 61 62 |
# File 'lib/stepper/models/active_record_additions.rb', line 60 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
56 57 58 |
# File 'lib/stepper/models/active_record_additions.rb', line 56 def last_step?(step = stepper_current_step) step == self.stepper_steps.last end |
#next_step ⇒ Object
74 75 76 77 78 |
# File 'lib/stepper/models/active_record_additions.rb', line 74 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
80 81 82 83 |
# File 'lib/stepper/models/active_record_additions.rb', line 80 def next_step! self.stepper_current_step = self.next_step self end |
#previous_step ⇒ Object
64 65 66 67 |
# File 'lib/stepper/models/active_record_additions.rb', line 64 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
69 70 71 72 |
# File 'lib/stepper/models/active_record_additions.rb', line 69 def previous_step! self.stepper_current_step = self.previous_step self end |
#stepper_current_step ⇒ Object
48 49 50 |
# File 'lib/stepper/models/active_record_additions.rb', line 48 def stepper_current_step self.send(self.class._stepper_current_step_column) end |
#stepper_current_step=(step) ⇒ Object
52 53 54 |
# File 'lib/stepper/models/active_record_additions.rb', line 52 def stepper_current_step=(step) self.send("#{self.class._stepper_current_step_column}=", step) end |
#stepper_current_step_column ⇒ Object
34 35 36 |
# File 'lib/stepper/models/active_record_additions.rb', line 34 def stepper_current_step_column self.class._stepper_current_step_column end |
#stepper_current_step_index ⇒ Object
42 43 44 |
# File 'lib/stepper/models/active_record_additions.rb', line 42 def stepper_current_step_index stepper_steps.index(stepper_current_step) end |
#stepper_steps ⇒ Object Also known as: steps
38 39 40 |
# File 'lib/stepper/models/active_record_additions.rb', line 38 def stepper_steps self.class._stepper_steps end |