module ActiveGraph::Relationship::Types::ClassMethods

Public Instance Methods

_wrapped_classes() click to toggle source
   # File lib/active_graph/relationship/types.rb
57 def _wrapped_classes
58   WRAPPED_CLASSES
59 end
add_wrapped_class(type) click to toggle source
   # File lib/active_graph/relationship/types.rb
61 def add_wrapped_class(type)
62   # WRAPPED_CLASSES[type.to_sym.downcase] = self.name
63   _wrapped_classes[type.to_sym] = self.name
64 end
inherited(subclass) click to toggle source
   # File lib/active_graph/relationship/types.rb
27 def inherited(subclass)
28   subclass.type subclass.namespaced_model_name, true
29 end
namespaced_model_name() click to toggle source
   # File lib/active_graph/relationship/types.rb
46 def namespaced_model_name
47   case ActiveGraph::Config[:module_handling]
48   when :demodulize
49     self.name.demodulize
50   when Proc
51     ActiveGraph::Config[:module_handling].call(self.name)
52   else
53     self.name
54   end
55 end
type(given_type = nil, auto = false) click to toggle source

When called without arguments, it will return the current setting or supply a default. When called with arguments, it will change the current setting. @param [String] given_type sets the relationship type when creating relationships via this class @param [Boolean] auto Should the given_type be changed in compliance with the gem's rel decorator setting?

   # File lib/active_graph/relationship/types.rb
35 def type(given_type = nil, auto = false)
36   case
37   when !given_type && type?
38     @type
39   when given_type
40     assign_type!(given_type, auto)
41   else
42     assign_type!(namespaced_model_name, true)
43   end
44 end
type?() click to toggle source
   # File lib/active_graph/relationship/types.rb
66 def type?
67   !!@type
68 end

Private Instance Methods

assign_type!(given_type, auto) click to toggle source
   # File lib/active_graph/relationship/types.rb
72 def assign_type!(given_type, auto)
73   @type = (auto ? decorated_rel_type(given_type) : given_type).tap do |type|
74     add_wrapped_class(type)
75   end
76 end