Sha256: 9c7fa1d46d48122605643d9999f366c4cbfe000855eeb117aaf4dd49240945f7

Contents?: true

Size: 763 Bytes

Versions: 5

Compression:

Stored size: 763 Bytes

Contents

class QuestionGroup < ActiveRecord::Base

  # Extending surveyor
  include "#{self.name}Extensions".constantize if Surveyor::Config['extend'].include?(self.name.underscore)
    
  has_many :questions
  has_one :dependency
  
  # Instance Methods
  def initialize(*args)
    super(*args)
    default_args
  end
  
  def default_args
    self.display_type ||= "inline"
  end

  def renderer
    display_type.blank? ? :default : display_type.to_sym
  end
  
  def dependent?
    self.dependency != nil
  end
  def triggered?(response_set)
    dependent? ? self.dependency.is_met?(response_set) : true
  end
  def css_class(response_set)
    [(dependent? ? "dependent" : nil), (triggered?(response_set) ? nil : "hidden"), custom_class].compact.join(" ")
  end
  
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
ccls-surveyor-1.0.0 app/models/question_group.rb
jakewendt-surveyor-0.11.3 app/models/question_group.rb
surveyor-0.12.1 app/models/question_group.rb
surveyor-0.11.0 app/models/question_group.rb
surveyor-0.10.0 app/models/question_group.rb