module ActiveWorker::Behavior::Hashable
Public Instance Methods
canonicalize(config, col)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 67 def canonicalize(config, col) config["_type"] ||= col.name.classify config["_id"] = config["_id"].to_s end
get_as_flat_hash_by_root_object(root_object)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 5 def get_as_flat_hash_by_root_object(root_object) configs = [] col = get_mongoid_collection col.find("root_object_id" => root_object.id).each do |config| canonicalize(config, col) configs << config end configs end
get_as_hash_by_root_object(root_object)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 15 def get_as_hash_by_root_object(root_object) configs = [] col = get_mongoid_collection col.find("root_object_id" => root_object.id, "parent_configuration_id" => nil).each do |config| config["configurations"] = get_children_for(col, config["_id"]) canonicalize(config, col) configs << config end configs end
get_children_for(col, parent_configuration_id)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 26 def get_children_for(col, parent_configuration_id) configs = [] col.find("parent_configuration_id" => parent_configuration_id).each do |config| config["configurations"] = get_children_for(col, config["_id"]) canonicalize(config, col) configs << config end configs end
get_mongoid_collection()
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 73 def get_mongoid_collection Mongoid.default_session.collections.select {|c| c.name == self.collection_name.to_s }.first end
get_renderable_children_for(col, parent_configuration_id)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 57 def get_renderable_children_for(col, parent_configuration_id) configs = [] col.find("parent_configuration_id" => parent_configuration_id, "renderable" => true).each do |config| config["configurations"] = get_renderable_children_for(col, config["_id"]) canonicalize(config, col) configs << config end configs end
get_renderable_hash_by_root_object(root_object)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 38 def get_renderable_hash_by_root_object(root_object) configs = [] col = get_mongoid_collection col.find("root_object_id" => root_object.id, "parent_configuration_id" => nil, "renderable" => true).each do |config| config["configurations"] = get_renderable_children_for(col, config["_id"]) canonicalize(config, col) configs << config end configs end
renderable_hash_for_configuration(configuration_id)
click to toggle source
# File lib/active_worker/behavior/hashable.rb, line 49 def renderable_hash_for_configuration(configuration_id) col = get_mongoid_collection config = col.find("_id" => configuration_id).first config["configurations"] = get_renderable_children_for(col, config["_id"]) canonicalize(config, col) config end