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?
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
20
21
22
|
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 20
def allow_join?
false
end
|
#belongs_to? ⇒ 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_cache ⇒ Object
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
32
33
34
|
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 32
def has_many? %i[has_many_records has_many_documents].include?(@association.macro)
end
|
#has_one? ⇒ Boolean
rubocop:disable Naming/PredicateName
28
29
30
|
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 28
def has_one? %i[has_one_record has_one_document].include?(@association.macro)
end
|
#inverse_klass ⇒ Object
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_key ⇒ Object
8
9
10
|
# File 'lib/active_scaffold/data_structures/association/active_mongoid.rb', line 8
def primary_key
@association[:primary_key]
end
|
#table_name ⇒ Object
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
|