class ActiveScaffold::DataStructures::Association::Mongoid

Public Class Methods

reflect_on_all_associations(klass) click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 47
def self.reflect_on_all_associations(klass)
  klass.relations.values
end

Public Instance Methods

association_primary_key() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 27
def association_primary_key
  @association.primary_key
end
belongs_to?() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 5
def belongs_to?
  # once Ruby 2.6 support is dropped, use macro_mapping? always
  defined?(::Mongoid::Association) ? macro_mapping?(:belongs_to) : super
end
foreign_type() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 31
def foreign_type
  @association.type
end
habtm?() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 18
def habtm?
  defined?(::Mongoid::Association) ? macro_mapping?(:has_and_belongs_to_many) : super
end
has_many?() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 14
def has_many? # rubocop:disable Naming/PredicateName
  defined?(::Mongoid::Association) ? macro_mapping?(:has_many) : super
end
has_one?() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 10
def has_one? # rubocop:disable Naming/PredicateName
  defined?(::Mongoid::Association) ? macro_mapping?(:has_one) : super
end
macro_mapping?(macro) click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 51
def macro_mapping?(macro)
  @association.is_a? ::Mongoid::Association::MACRO_MAPPING[macro]
end
polymorphic?() click to toggle source

polymorphic belongs_to

# File lib/active_scaffold/data_structures/association/mongoid.rb, line 23
def polymorphic?
  belongs_to? && @association.polymorphic?
end
quoted_primary_key() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 43
def quoted_primary_key
  '_id'
end
quoted_table_name() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 39
def quoted_table_name
  table_name
end
table_name() click to toggle source
# File lib/active_scaffold/data_structures/association/mongoid.rb, line 35
def table_name
  @association.klass.collection.name
end