Class: Validation

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

Instance Method Summary collapse

Methods included from Surveyor::Models::ValidationMethods

#conditions_hash, #is_valid?

Instance Method Details

#unparse(dsl) ⇒ Object

nonblock



140
141
142
143
144
145
146
147
# File 'lib/surveyor/unparser.rb', line 140

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