Class: Rapidfire::QuestionForm

Inherits:
BaseService show all
Defined in:
app/services/rapidfire/question_form.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 = {}) ⇒ QuestionForm

Returns a new instance of QuestionForm.



27
28
29
30
31
# File 'app/services/rapidfire/question_form.rb', line 27

def initialize(params = {})
  from_question_to_attributes(params[:question]) if params[:question]
  super(params)
  @question ||= survey.questions.new
end

Instance Attribute Details

#answer_greater_than_or_equal_toObject

Returns the value of attribute answer_greater_than_or_equal_to.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

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.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

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.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def answer_maximum_length
  @answer_maximum_length
end

#answer_minimum_lengthObject

Returns the value of attribute answer_minimum_length.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def answer_minimum_length
  @answer_minimum_length
end

#answer_optionsObject

Returns the value of attribute answer_options.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def answer_options
  @answer_options
end

#answer_presenceObject

Returns the value of attribute answer_presence.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def answer_presence
  @answer_presence
end

#default_textObject

Returns the value of attribute default_text.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def default_text
  @default_text
end

#placeholderObject

Returns the value of attribute placeholder.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def placeholder
  @placeholder
end

#positionObject

Returns the value of attribute position.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def position
  @position
end

#questionObject

Returns the value of attribute question.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def question
  @question
end

#question_textObject

Returns the value of attribute question_text.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def question_text
  @question_text
end

#surveyObject

Returns the value of attribute survey.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def survey
  @survey
end

#typeObject

Returns the value of attribute type.



20
21
22
# File 'app/services/rapidfire/question_form.rb', line 20

def type
  @type
end

Instance Method Details

#saveObject



33
34
35
# File 'app/services/rapidfire/question_form.rb', line 33

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