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, included, #is_valid?

Instance Method Details

#unparse(dsl) ⇒ Object

nonblock



128
129
130
131
132
133
134
# File 'lib/surveyor/unparser.rb', line 128

def unparse(dsl)
  attrs = (self.attributes.diff Validation.new.attributes).delete_if{|k,v| %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