class ProfileWizard::Models::Step

Attributes

profile_wizard_step_required[RW]
profile_wizard_step_title[RW]
questions[RW]

Public Class Methods

new(step_key, step_schema) click to toggle source
# File lib/profile_wizard/models/step.rb, line 7
def initialize(step_key, step_schema)
  @questions = {}
  @meta_info = {}
  @meta_info[:title] = step_schema[:title] || ActiveSupport::Inflector.humanize(step_key).titleize
  @meta_info[:required] = step_schema[:required] || false
  step_ref = self
  step_schema[:questions].each do |question_key, question_schema|
    self.class.class_eval do
      define_method(question_key) do
        @questions[question_key] ||= ProfileWizard::Models::Question.new(question_key, question_schema, step_ref)
      end

      define_method("#{question_key}=") do |val|
        @questions[question_key].answer = val
      end
    end
    send(question_key)
  end
end

Public Instance Methods

required?() click to toggle source
# File lib/profile_wizard/models/step.rb, line 32
def required?
  @meta_info[:required]
end
title() click to toggle source

We are making an assumption that there won't be a question with the key `:title`

# File lib/profile_wizard/models/step.rb, line 28
def title
  @meta_info[:title]
end