Class: Survey

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Surveyor::Models::SurveyMethods
Defined in:
lib/surveyor/unparser.rb,
app/models/survey.rb,
lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb,
lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb

Overview

Surveyor models with extra parsing methods

Instance Method Summary collapse

Methods included from Surveyor::Models::SurveyMethods

#activate!, #active?, #active_as_of?, #as_json, #deactivate!, #default_access_code, #default_args, #filtered_for_json, #generate_access_code, included, #increment_version, #initialize, #translation

Instance Method Details

#unparse(dsl) ⇒ Object

block



16
17
18
19
20
21
22
# File 'lib/surveyor/unparser.rb', line 16

def unparse(dsl)
  attrs = (self.attributes.diff Survey.new(:title => title).attributes).delete_if{|k,v| %w(created_at updated_at inactive_at id title access_code api_id).include? k}.symbolize_keys!
  dsl << "survey \"#{title}\""
  dsl << (attrs.blank? ? " do\n" : ", #{attrs.inspect.gsub(/\{|\}/, "")} do\n")
  sections.each{|section| section.unparse(dsl)}
  dsl << "end\n"
end