Module: SurveyorGui::Models::AnswerMethods

Included in:
Answer
Defined in:
lib/surveyor_gui/models/answer_methods.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/surveyor_gui/models/answer_methods.rb', line 5

def self.included(base)
  base.send :belongs_to, :question
  base.send :has_many, :responses
  base.send :belongs_to, :column
  base.send :default_scope, lambda { base.order('display_order') }
  base.send :attr_accessible, :text, :response_class, :display_order, :original_choice, :hide_label, :question_id, 
            :display_type, :is_comment, :column if defined? ActiveModel::MassAssignmentSecurity
  base.send :scope, :is_not_comment, -> { base.where(is_comment: false) }
  base.send :scope, :is_comment, -> { base.where(is_comment: true) }
end

Instance Method Details

#split_or_hidden_text(part = nil) ⇒ Object



16
17
18
19
20
# File 'lib/surveyor_gui/models/answer_methods.rb', line 16

def split_or_hidden_text(part = nil)
  #return "" if hide_label.to_s == "true"
  return "" if display_type.to_s == "hidden_label"
  part == :pre ? text.split("|",2)[0] : (part == :post ? text.split("|",2)[1] : text)
end