Module: RailsDynamicAssociations::Config::Naming

Defined in:
lib/rails_dynamic_associations/config.rb

Instance Method Summary collapse

Instance Method Details

#opposite(direction) ⇒ Object



20
21
22
# File 'lib/rails_dynamic_associations/config.rb', line 20

def opposite direction
	find { |d| d != direction }
end

#opposite_shortcutsObject



24
25
26
27
28
29
30
# File 'lib/rails_dynamic_associations/config.rb', line 24

def opposite_shortcuts
	shortcuts.each_with_object({}) do |(key, value), hash|
		hash[key] = shortcuts.values.find do |v|
			v != value
		end
	end
end

#recursiveObject



12
13
14
15
16
17
18
# File 'lib/rails_dynamic_associations/config.rb', line 12

def recursive
	config.each_with_object({}) do |(key, value), hash|
		hash[
			value[:selfed].to_s.pluralize.to_sym
		] = value[:recursive]
	end
end

#selfedObject



8
9
10
# File 'lib/rails_dynamic_associations/config.rb', line 8

def selfed
	config :selfed
end

#shortcutsObject



4
5
6
# File 'lib/rails_dynamic_associations/config.rb', line 4

def shortcuts
	config :shortcut
end