Class: Rapidfire::QuestionProxy

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion
Defined in:
app/models/rapidfire/question_proxy.rb

Constant Summary collapse

AVAILABLE_QUESTIONS =
[
 Rapidfire::Questions::Checkbox,
 Rapidfire::Questions::Date,
 Rapidfire::Questions::Long,
 Rapidfire::Questions::Numeric,
 Rapidfire::Questions::Radio,
 Rapidfire::Questions::Select,
 Rapidfire::Questions::Short,
]
QUESTION_TYPES =
AVAILABLE_QUESTIONS.inject({}) do |result, question|
  question_name = question.to_s.split("::").last
  result[question_name] = question.to_s
  result
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ QuestionProxy

Returns a new instance of QuestionProxy.



38
39
40
41
42
# File 'app/models/rapidfire/question_proxy.rb', line 38

def initialize(params = {})
  from_question_to_attributes(params[:question]) if params[:question]
  params.each { |k, v| send("#{k}=", v) }
  @question ||= question_group.questions.new
end

Instance Attribute Details

#answer_greater_than_or_equal_toObject

Returns the value of attribute answer_greater_than_or_equal_to.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def answer_greater_than_or_equal_to
  @answer_greater_than_or_equal_to
end

#answer_less_than_or_equal_toObject

Returns the value of attribute answer_less_than_or_equal_to.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def answer_less_than_or_equal_to
  @answer_less_than_or_equal_to
end

#answer_maximum_lengthObject

Returns the value of attribute answer_maximum_length.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def answer_maximum_length
  @answer_maximum_length
end

#answer_minimum_lengthObject

Returns the value of attribute answer_minimum_length.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def answer_minimum_length
  @answer_minimum_length
end

#answer_optionsObject

Returns the value of attribute answer_options.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def answer_options
  @answer_options
end

#answer_presenceObject

Returns the value of attribute answer_presence.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def answer_presence
  @answer_presence
end

#questionObject

Returns the value of attribute question.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def question
  @question
end

#question_groupObject

Returns the value of attribute question_group.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def question_group
  @question_group
end

#question_textObject

Returns the value of attribute question_text.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def question_text
  @question_text
end

#typeObject

Returns the value of attribute type.



23
24
25
# File 'app/models/rapidfire/question_proxy.rb', line 23

def type
  @type
end

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/rapidfire/question_proxy.rb', line 30

def persisted?
  false
end

#saveObject



44
45
46
# File 'app/models/rapidfire/question_proxy.rb', line 44

def save
  @question.new_record? ? create_question : update_question
end

#to_modelObject



34
35
36
# File 'app/models/rapidfire/question_proxy.rb', line 34

def to_model
  question
end