module ActiveModel::Associations::OverrideMethods::ClassMethods

Public Instance Methods

clear_reflections_cache() click to toggle source
# File lib/active_model/associations/override_methods.rb, line 26
def clear_reflections_cache
  @__reflections = nil
end
dangerous_attribute_method?(name) click to toggle source

override

# File lib/active_model/associations/override_methods.rb, line 17
def dangerous_attribute_method?(name)
  false
end
default_scopes() click to toggle source
# File lib/active_model/associations/override_methods.rb, line 30
def default_scopes
  []
end
generated_association_methods() click to toggle source
# File lib/active_model/associations/override_methods.rb, line 6
def generated_association_methods
  @generated_association_methods ||= begin
    mod = const_set(:GeneratedAssociationMethods, Module.new)
    include mod
    mod
  end
end
Also aliased as: generated_feature_methods
generated_feature_methods()
pluralize_table_names() click to toggle source

dummy table name

# File lib/active_model/associations/override_methods.rb, line 22
def pluralize_table_names
  self.to_s.pluralize
end

Protected Instance Methods

compute_type(type_name) click to toggle source
# File lib/active_model/associations/override_methods.rb, line 36
def compute_type(type_name)
  if type_name.match(/^::/)
    # If the type is prefixed with a scope operator then we assume that
    # the type_name is an absolute reference.
    ActiveSupport::Dependencies.constantize(type_name)
  else
    # Build a list of candidates to search for
    candidates = []
    name.scan(/::|$/) { candidates.unshift "#{$`}::#{type_name}" }
    candidates << type_name

    candidates.each do |candidate|
      begin
        constant = ActiveSupport::Dependencies.constantize(candidate)
        return constant if candidate == constant.to_s
        # We don't want to swallow NoMethodError < NameError errors
      rescue NoMethodError
        raise
      rescue NameError
      end
    end

    raise NameError.new("uninitialized constant #{candidates.first}", candidates.first)
  end
end