Class: ActiveScaffold::DataStructures::Association::ActiveMongoid

Inherits:
Mongoid show all
Defined in:
lib/active_scaffold/data_structures/association/active_mongoid.rb

Instance Attribute Summary

Attributes inherited from Abstract

#reverse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mongoid

#association_primary_key, #foreign_type, #habtm?, #macro_mapping?, #polymorphic?, #quoted_primary_key, #quoted_table_name

Methods inherited from Abstract

#as, #collection?, #counter_cache_hack?, #habtm?, #initialize, #inverse_for?, #klass, #polymorphic?, #quoted_primary_key, #quoted_table_name, #readonly?, #respond_to_target?, #reverse_association, #scope, #singular?, #source_reflection, #through?, #through_collection?, #through_reflection, #through_singular?

Constructor Details

This class inherits a constructor from ActiveScaffold::DataStructures::Association::Abstract

Class Method Details

.reflect_on_all_associations(klass) ⇒ Object



3
4
5
6
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 3

def self.reflect_on_all_associations(klass)
  return [] unless klass.respond_to? :am_relations
  klass.am_relations.values
end

Instance Method Details

#allow_join?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 20

def allow_join?
  false
end

#belongs_to?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 24

def belongs_to?
  %i[belongs_to_record belongs_to_document].include?(@association.macro)
end

#counter_cacheObject



12
13
14
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 12

def counter_cache
  @association[:counter_cache]
end

#has_many?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


32
33
34
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 32

def has_many? # rubocop:disable Naming/PredicateName
  %i[has_many_records has_many_documents].include?(@association.macro)
end

#has_one?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


28
29
30
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 28

def has_one? # rubocop:disable Naming/PredicateName
  %i[has_one_record has_one_document].include?(@association.macro)
end

#inverse_klassObject



16
17
18
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 16

def inverse_klass
  as ? @association[:inverse_class_name].constantize : super
end

#primary_keyObject



8
9
10
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 8

def primary_key
  @association[:primary_key]
end

#table_nameObject



36
37
38
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 36

def table_name
  @association.klass < ActiveRecord::Base ? @association.klass.table_name : super
end