module RailsDynamicAssociations::Config::Naming

Public Instance Methods

opposite(direction) click to toggle source
# File lib/rails_dynamic_associations/config.rb, line 20
def opposite direction
        find { |d| d != direction }
end
opposite_shortcuts() click to toggle source
# 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
recursive() click to toggle source
# 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
selfed() click to toggle source
# File lib/rails_dynamic_associations/config.rb, line 8
def selfed
        config :selfed
end
shortcuts() click to toggle source
# File lib/rails_dynamic_associations/config.rb, line 4
def shortcuts
        config :shortcut
end

Private Instance Methods

config(section = nil) click to toggle source
# File lib/rails_dynamic_associations/config.rb, line 34
def config section = nil
        if section
                config.each_with_object({}) do |(key, value), hash|
                        hash[key] = value[section]
                end
        else
                Config.association_names[:directions] # TODO: DRY
        end
end