Class: WizardSteps::Step

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model, ActiveModel::Validations::Callbacks
Defined in:
lib/wizard_steps/step.rb

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


12
13
14
# File 'lib/wizard_steps/step.rb', line 12

def contains_personal_details?
  false
end

.keyObject



8
9
10
# File 'lib/wizard_steps/step.rb', line 8

def key
  name.split("::").last.underscore
end

.titleObject



16
17
18
# File 'lib/wizard_steps/step.rb', line 16

def title
  key.humanize
end

Instance Method Details

#can_proceed?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/wizard_steps/step.rb', line 38

def can_proceed?
  true
end

#exportObject



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

Returns:

  • (Boolean)


42
43
44
# File 'lib/wizard_steps/step.rb', line 42

def persisted?
  !id.nil?
end

#reviewable_answersObject



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

Returns:

  • (Boolean)


46
47
48
# File 'lib/wizard_steps/step.rb', line 46

def skipped?
  false
end