Module: ActiveGraph::RelWrapping
- Defined in:
- lib/active_graph/relationship/rel_wrapper.rb
Class Method Summary collapse
Class Method Details
.class_from_type(type) ⇒ Object
[View source]
26 27 28 |
# File 'lib/active_graph/relationship/rel_wrapper.rb', line 26 def class_from_type(type) ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] = type.to_s.downcase.camelize end |
.wrapper(rel) ⇒ Object
[View source]
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_graph/relationship/rel_wrapper.rb', line 11 def wrapper(rel) rel.properties.symbolize_keys! begin most_concrete_class = class_from_type(rel.type).constantize return rel unless most_concrete_class < ActiveGraph::Relationship most_concrete_class.new rescue NameError => e raise e unless e. =~ /(uninitialized|wrong) constant/ return rel end.tap do |wrapped_rel| wrapped_rel.init_on_load(rel, rel.start_node_id, rel.end_node_id, rel.type) end end |