Module: Neo4j::ActiveRel::Types::ClassMethods

Includes:
Shared::RelTypeConverters
Defined in:
lib/neo4j/active_rel/types.rb

Instance Method Summary collapse

Methods included from Shared::RelTypeConverters

#decorated_rel_type, decorated_rel_type, rel_transformer

Instance Method Details

#_wrapped_classesObject



59
60
61
# File 'lib/neo4j/active_rel/types.rb', line 59

def _wrapped_classes
  WRAPPED_CLASSES
end

#add_wrapped_class(type) ⇒ Object



63
64
65
66
# File 'lib/neo4j/active_rel/types.rb', line 63

def add_wrapped_class(type)
  # WRAPPED_CLASSES[type.to_sym.downcase] = self.name
  _wrapped_classes[type.to_sym] = self.name
end

#inherited(subclass) ⇒ Object



27
28
29
# File 'lib/neo4j/active_rel/types.rb', line 27

def inherited(subclass)
  subclass.type subclass.namespaced_model_name, true
end

#namespaced_model_nameObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/neo4j/active_rel/types.rb', line 48

def namespaced_model_name
  case Neo4j::Config[:module_handling]
  when :demodulize
    self.name.demodulize
  when Proc
    Neo4j::Config[:module_handling].call(self.name)
  else
    self.name
  end
end

#rel_type?Boolean

Returns:



68
69
70
# File 'lib/neo4j/active_rel/types.rb', line 68

def rel_type?
  !!@rel_type
end

#type(given_type = nil, auto = false) ⇒ Object Also known as: rel_type, _type

When called without arguments, it will return the current setting or supply a default. When called with arguments, it will change the current setting.

Parameters:

  • given_type (String) (defaults to: nil)

    sets the relationship type when creating relationships via this class

  • auto (Boolean) (defaults to: false)

    Should the given_type be changed in compliance with the gem’s rel decorator setting?



35
36
37
38
39
40
41
42
43
44
# File 'lib/neo4j/active_rel/types.rb', line 35

def type(given_type = nil, auto = false)
  case
  when !given_type && rel_type?
    @rel_type
  when given_type
    assign_type!(given_type, auto)
  else
    assign_type!(namespaced_model_name, true)
  end
end