Class: WizardSteps::Step
- Inherits:
-
Object
- Object
- WizardSteps::Step
- Includes:
- ActiveModel::Attributes, ActiveModel::Model, ActiveModel::Validations::Callbacks
- Defined in:
- lib/wizard_steps/step.rb
Class Method Summary collapse
Instance Method Summary collapse
- #can_proceed? ⇒ Boolean
- #export ⇒ Object
-
#initialize(wizard, store, attributes = {}, *args) ⇒ Step
constructor
A new instance of Step.
- #persisted? ⇒ Boolean
- #reviewable_answers ⇒ Object
- #save! ⇒ Object
- #skipped? ⇒ Boolean
Constructor Details
#initialize(wizard, store, attributes = {}, *args) ⇒ Step
Returns a new instance of Step.
24 25 26 27 28 29 30 |
# File 'lib/wizard_steps/step.rb', line 24 def initialize(wizard, store, attributes = {}, *args) @wizard = wizard @store = store super(*args) assign_attributes attributes_from_store assign_attributes attributes end |
Class Method Details
.contains_personal_details? ⇒ Boolean
12 13 14 |
# File 'lib/wizard_steps/step.rb', line 12 def contains_personal_details? false end |
.key ⇒ Object
8 9 10 |
# File 'lib/wizard_steps/step.rb', line 8 def key name.split("::").last.underscore end |
.title ⇒ Object
16 17 18 |
# File 'lib/wizard_steps/step.rb', line 16 def title key.humanize end |
Instance Method Details
#can_proceed? ⇒ Boolean
38 39 40 |
# File 'lib/wizard_steps/step.rb', line 38 def can_proceed? true end |
#export ⇒ Object
50 51 52 53 54 |
# File 'lib/wizard_steps/step.rb', line 50 def export return {} if skipped? Hash[attributes.keys.zip([])].merge attributes_from_store end |
#persisted? ⇒ Boolean
42 43 44 |
# File 'lib/wizard_steps/step.rb', line 42 def persisted? !id.nil? end |
#reviewable_answers ⇒ Object
56 57 58 |
# File 'lib/wizard_steps/step.rb', line 56 def reviewable_answers attributes end |
#save! ⇒ Object
32 33 34 35 36 |
# File 'lib/wizard_steps/step.rb', line 32 def save! return false unless valid? persist_to_store end |
#skipped? ⇒ Boolean
46 47 48 |
# File 'lib/wizard_steps/step.rb', line 46 def skipped? false end |