Module: Surveyor::Models::QuestionGroupMethods

Included in:
QuestionGroup
Defined in:
lib/surveyor/models/question_group_methods.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
# File 'lib/surveyor/models/question_group_methods.rb', line 4

def self.included(base)
  # Associations
  base.send :has_many, :questions
  base.send :has_one, :dependency
end

Instance Method Details

#css_class(response_set) ⇒ Object



34
35
36
# File 'lib/surveyor/models/question_group_methods.rb', line 34

def css_class(response_set)
  [(dependent? ? "g_dependent" : nil), (triggered?(response_set) ? nil : "g_hidden"), custom_class].compact.join(" ")
end

#default_argsObject



16
17
18
# File 'lib/surveyor/models/question_group_methods.rb', line 16

def default_args
  self.display_type ||= "inline"
end

#dependent?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/surveyor/models/question_group_methods.rb', line 28

def dependent?
  self.dependency != nil
end

#display_type=(val) ⇒ Object



24
25
26
# File 'lib/surveyor/models/question_group_methods.rb', line 24

def display_type=(val)
  write_attribute(:display_type, val.nil? ? nil : val.to_s)
end

#initialize(*args) ⇒ QuestionGroupMethods

Instance Methods

Returns:



11
12
13
14
# File 'lib/surveyor/models/question_group_methods.rb', line 11

def initialize(*args)
  super(*args)
  default_args
end

#rendererObject



20
21
22
# File 'lib/surveyor/models/question_group_methods.rb', line 20

def renderer
  display_type.blank? ? :default : display_type.to_sym
end

#triggered?(response_set) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/surveyor/models/question_group_methods.rb', line 31

def triggered?(response_set)
  dependent? ? self.dependency.is_met?(response_set) : true
end