class ActiveExplorer::Writer
Public Class Methods
new(exploration)
click to toggle source
# File lib/writer.rb, line 3 def initialize(exploration) @exploration = exploration end
Public Instance Methods
write()
click to toggle source
# File lib/writer.rb, line 7 def write exploration_hash = @exploration.get_hash puts "\nExplored #{exploration_hash[:class_name]}(#{exploration_hash[:attributes][:id]}):\n\n" write_object(exploration_hash) puts "\n" end
Private Instance Methods
write_object(object, level = 0)
click to toggle source
# File lib/writer.rb, line 17 def write_object(object, level = 0) class_name = object[:class_name] id = object[:attributes][:id] attributes = object[:attributes] error_message = object[:error_message] attributes.delete :id margin = ' ' * level if level > 0 margin[-2] = '->' margin += object[:association] == :belongs_to ? 'belongs to ' : 'has ' end puts "#{margin}#{class_name}(#{id}) #{attributes}" if error_message.present? margin = ' ' * level puts "#{margin}(#{error_message})" if error_message.present? end write_objects object[:subobjects], level + 1 unless object[:subobjects].nil? end
write_objects(objects, level)
click to toggle source
# File lib/writer.rb, line 42 def write_objects(objects, level) objects.each do |object| write_object object, level end end