Class: ValidationCondition

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

Instance Method Summary collapse

Methods included from Surveyor::Models::ValidationConditionMethods

#is_valid?, #to_hash

Methods included from Surveyor::ActsAsResponse

#as

Instance Method Details

#unparse(dsl) ⇒ Object

nonblock



152
153
154
155
156
157
158
159
160
# File 'lib/surveyor/unparser.rb', line 152

def unparse(dsl)
  with_defaults = ValidationCondition.new
  attrs = self.attributes.delete_if{|k,v| with_defaults[k] == v or %w(created_at updated_at operator rule_key id validation_id).include? k}.symbolize_keys!
  dsl << "  " if validation.answer.question.part_of_group?
  dsl << "    condition"
  dsl << "_#{rule_key}" unless rule_key.blank?
  dsl << " \"#{operator}\""
  dsl << (attrs.blank? ? "\n" : ", #{attrs.inspect.gsub(/\{|\}/, "")}\n")
end