Class: ActiveScaffold::DataStructures::Association::Mongoid
- Inherits:
-
Abstract
show all
- Defined in:
- lib/active_scaffold/data_structures/association/mongoid.rb
Instance Attribute Summary
Attributes inherited from Abstract
#reverse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Abstract
#allow_join?, #as, #collection?, #counter_cache, #counter_cache_hack?, #initialize, #inverse_for?, #klass, #primary_key, #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
47
48
49
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 47
def self.reflect_on_all_associations(klass)
klass.relations.values
end
|
Instance Method Details
#association_primary_key ⇒ Object
27
28
29
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 27
def association_primary_key
@association.primary_key
end
|
#belongs_to? ⇒ Boolean
5
6
7
8
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 5
def belongs_to?
defined?(::Mongoid::Association) ? macro_mapping?(:belongs_to) : super
end
|
#foreign_type ⇒ Object
31
32
33
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 31
def foreign_type
@association.type
end
|
#habtm? ⇒ Boolean
18
19
20
|
# 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? ⇒ Boolean
rubocop:disable Naming/PredicateName
14
15
16
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 14
def has_many? defined?(::Mongoid::Association) ? macro_mapping?(:has_many) : super
end
|
#has_one? ⇒ Boolean
rubocop:disable Naming/PredicateName
10
11
12
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 10
def has_one? defined?(::Mongoid::Association) ? macro_mapping?(:has_one) : super
end
|
#macro_mapping?(macro) ⇒ Boolean
51
52
53
|
# 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? ⇒ Boolean
23
24
25
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 23
def polymorphic?
belongs_to? && @association.polymorphic?
end
|
#quoted_primary_key ⇒ Object
43
44
45
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 43
def quoted_primary_key
'_id'
end
|
#quoted_table_name ⇒ Object
39
40
41
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 39
def quoted_table_name
table_name
end
|
#table_name ⇒ Object
35
36
37
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 35
def table_name
@association.klass.collection.name
end
|