Class: Dependency

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Surveyor::Models::DependencyMethods
Defined in:
app/models/dependency.rb,
lib/surveyor/unparser.rb

Instance Method Summary collapse

Methods included from Surveyor::Models::DependencyMethods

#conditions_hash, #is_met?, #question_group_id=, #question_id=

Instance Method Details

#unparse(dsl) ⇒ Object

nonblock



93
94
95
96
97
98
99
100
# File 'lib/surveyor/unparser.rb', line 93

def unparse(dsl)
  with_defaults = Dependency.new
  attrs = self.attributes.delete_if{|k,v| with_defaults[k] == v or %w(created_at updated_at id question_id).include?(k) }.symbolize_keys!
  dsl << "  " if question.part_of_group?
  dsl << "    dependency"
  dsl << (attrs.blank? ? "\n" : " #{attrs.inspect.gsub(/\{|\}/, "")}\n")
  dependency_conditions.each{|dependency_condition| dependency_condition.unparse(dsl)}
end