module ActiveGraph::RelWrapping
Public Class Methods
class_from_type(type)
click to toggle source
# File lib/active_graph/relationship/rel_wrapper.rb 26 def class_from_type(type) 27 ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] = type.to_s.downcase.camelize 28 end
wrapper(rel)
click to toggle source
# File lib/active_graph/relationship/rel_wrapper.rb 11 def wrapper(rel) 12 rel.properties.symbolize_keys! 13 begin 14 most_concrete_class = class_from_type(rel.type).constantize 15 return rel unless most_concrete_class < ActiveGraph::Relationship 16 most_concrete_class.new 17 rescue NameError => e 18 raise e unless e.message =~ /(uninitialized|wrong) constant/ 19 20 return rel 21 end.tap do |wrapped_rel| 22 wrapped_rel.init_on_load(rel, rel.start_node_id, rel.end_node_id, rel.type) 23 end 24 end