Class: HatTrick::Step
- Inherits:
-
Object
- Object
- HatTrick::Step
- Defined in:
- lib/hat_trick/step.rb
Instance Attribute Summary collapse
-
#buttons ⇒ Object
readonly
Returns the value of attribute buttons.
-
#next_step ⇒ Object
Returns the value of attribute next_step.
-
#redirect_from ⇒ Object
Returns the value of attribute redirect_from.
-
#skipped ⇒ Object
writeonly
Sets the attribute skipped.
-
#step_def ⇒ Object
readonly
Returns the value of attribute step_def.
-
#wizard ⇒ Object
readonly
Returns the value of attribute wizard.
Instance Method Summary collapse
- #add_button(button) ⇒ Object
- #as_json(options = nil) ⇒ Object
- #delete_button(type) ⇒ Object
-
#initialize(step_def, wizard) ⇒ Step
constructor
A new instance of Step.
- #mark_as_visited ⇒ Object
- #redirect? ⇒ Boolean
- #skipped? ⇒ Boolean
- #visited? ⇒ Boolean
Constructor Details
#initialize(step_def, wizard) ⇒ Step
Returns a new instance of Step.
17 18 19 20 21 22 |
# File 'lib/hat_trick/step.rb', line 17 def initialize(step_def, wizard) @step_def = step_def @buttons = step_def..dup @wizard = wizard @skipped = step_def.skipped? end |
Instance Attribute Details
#buttons ⇒ Object (readonly)
Returns the value of attribute buttons.
5 6 7 |
# File 'lib/hat_trick/step.rb', line 5 def @buttons end |
#next_step ⇒ Object
Returns the value of attribute next_step.
6 7 8 |
# File 'lib/hat_trick/step.rb', line 6 def next_step @next_step end |
#redirect_from ⇒ Object
Returns the value of attribute redirect_from.
6 7 8 |
# File 'lib/hat_trick/step.rb', line 6 def redirect_from @redirect_from end |
#skipped=(value) ⇒ Object (writeonly)
Sets the attribute skipped
7 8 9 |
# File 'lib/hat_trick/step.rb', line 7 def skipped=(value) @skipped = value end |
#step_def ⇒ Object (readonly)
Returns the value of attribute step_def.
5 6 7 |
# File 'lib/hat_trick/step.rb', line 5 def step_def @step_def end |
#wizard ⇒ Object (readonly)
Returns the value of attribute wizard.
5 6 7 |
# File 'lib/hat_trick/step.rb', line 5 def wizard @wizard end |
Instance Method Details
#add_button(button) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/hat_trick/step.rb', line 24 def () @buttons.delete_if do |b| b.keys.first == .keys.first && b[b.keys.first][:default] end @buttons << end |
#as_json(options = nil) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/hat_trick/step.rb', line 51 def as_json( = nil) json = { :name => name, :fieldset => fieldset } json[:buttons] = .empty? ? [] : json[:first] = first? json[:redirect] = redirect? json[:redirectFrom] = redirect_from json end |
#delete_button(type) ⇒ Object
31 32 33 |
# File 'lib/hat_trick/step.rb', line 31 def (type) @buttons.delete_if { |b| b.keys.first == type } end |
#mark_as_visited ⇒ Object
47 48 49 |
# File 'lib/hat_trick/step.rb', line 47 def mark_as_visited visited_steps << self.to_sym end |
#redirect? ⇒ Boolean
39 40 41 |
# File 'lib/hat_trick/step.rb', line 39 def redirect? redirect_from.present? end |
#skipped? ⇒ Boolean
35 36 37 |
# File 'lib/hat_trick/step.rb', line 35 def skipped? @skipped || (skipped_steps.include?(self.to_sym) && !visited?) end |
#visited? ⇒ Boolean
43 44 45 |
# File 'lib/hat_trick/step.rb', line 43 def visited? visited_steps.include? self.to_sym end |