Class: ActiveRecordSurvey::Survey

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/active_record_survey/survey.rb

Instance Method Summary collapse

Instance Method Details

#as_map(*args) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/active_record_survey/survey.rb', line 12

def as_map(*args)
  options = args.extract_options!
  options[:node_maps] ||= self.node_maps

  self.node_maps.select { |i| !i.parent && !i.marked_for_destruction? }.collect { |i|
    i.as_map(options)
  }
end

#root_nodeObject



8
9
10
# File 'lib/active_record_survey/survey.rb', line 8

def root_node
  self.node_maps.includes(:node).select { |i| i.depth === 0 }.first
end