Class: DependencyCondition

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

Instance Method Summary collapse

Methods included from Surveyor::Models::DependencyConditionMethods

included, #to_hash

Instance Method Details

#unparse(dsl) ⇒ Object

nonblock



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

def unparse(dsl)
  attrs = (self.attributes.diff Dependency.new.attributes).delete_if{|k,v| %w(created_at updated_at question_id question_group_id rule_key rule operator id dependency_id answer_id).include? k}.symbolize_keys!
  dsl << "  " if dependency.question.part_of_group?
  dsl << "    condition"
  dsl << "_#{rule_key}" unless rule_key.blank?
  dsl << " :q_#{question.reference_identifier}, \"#{operator}\""
  dsl << (attrs.blank? ? ", {:answer_reference=>\"#{answer && answer.reference_identifier}\"}\n" : ", {#{attrs.inspect.gsub(/\{|\}/, "")}, :answer_reference=>\"#{answer && answer.reference_identifier}\"}\n")
end