module Neo4j::Shared::RelTypeConverters
This module controls changes to relationship type based on Neo4j::Config.transform_rel_type. It's used whenever a rel type is automatically determined based on ActiveRel
model name or association type.
Public Class Methods
@param [String,Symbol] type The raw string or symbol to be used as the basis of the relationship type @return [String] A string that conforms to the set rel type conversion setting.
# File lib/neo4j/shared/rel_type_converters.rb 25 def decorated_rel_type(type) 26 type = type.to_s 27 decorated_type = case rel_transformer 28 when :upcase 29 type.underscore.upcase 30 when :downcase 31 type.underscore.downcase 32 when :legacy 33 "##{type.underscore.downcase}" 34 when :none 35 type 36 else 37 type.underscore.upcase 38 end 39 decorated_type.tap { |s| s.gsub!('/', '::') if type.include?('::') } 40 end
Determines how relationship types should look when inferred based on association or ActiveRel
model name. With the exception of `:none`, all options will call `underscore`, so `ThisClass` becomes `this_class`, with capitalization determined by the specific option passed. Valid options:
-
:upcase - `:this_class`, `ThisClass`, `thiS_claSs` (if you don't like yourself) becomes `THIS_CLASS`
-
:downcase - same as above, only… downcased.
-
:legacy - downcases and prepends `#`, so ThisClass becomes `#this_class`
-
:none - uses the string version of whatever is passed with no modifications
# File lib/neo4j/shared/rel_type_converters.rb 19 def rel_transformer 20 @rel_transformer ||= Neo4j::Config[:transform_rel_type].nil? ? :upcase : Neo4j::Config[:transform_rel_type] 21 end
Public Instance Methods
# File lib/neo4j/shared/rel_type_converters.rb 6 def decorated_rel_type(type) 7 @decorated_rel_type ||= Neo4j::Shared::RelTypeConverters.decorated_rel_type(type) 8 end