class CatEngine::Question
Attributes
response[RW]
responses_attributes[RW]
selected_response_index[RW]
Public Class Methods
new(attributes = nil)
click to toggle source
# File lib/cat_engine/question.rb, line 9 def initialize attributes = nil assign_attributes(attributes || {}) end
Public Instance Methods
context_and_title()
click to toggle source
# File lib/cat_engine/question.rb, line 13 def context_and_title [context, title].select(&:present?).join(" ") end
persisted?()
click to toggle source
# File lib/cat_engine/question.rb, line 21 def persisted?; false; end
selected_response()
click to toggle source
# File lib/cat_engine/question.rb, line 25 def selected_response if selected_response_index responses_attributes[selected_response_index] else { id: "00000000-0000-0000-0000-000000000000", title: response || "Skipped" } end end
xml=(xml)
click to toggle source
# File lib/cat_engine/question.rb, line 17 def xml= xml assign_attributes XMLMapper.new(xml).to_h end
Private Instance Methods
assign_attributes(attributes)
click to toggle source
# File lib/cat_engine/question.rb, line 35 def assign_attributes attributes attributes.each do |key, value| send :"#{key}=", value end end