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, #cache_count?, #collection?, #counter_cache, #counter_cache_hack?, #initialize, #inverse_for?, #klass, #nested?, #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
49
50
51
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 49
def self.reflect_on_all_associations(klass)
klass.relations.values
end
|
Instance Method Details
#association_primary_key ⇒ Object
29
30
31
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 29
def association_primary_key
@association.primary_key
end
|
#belongs_to? ⇒ Boolean
7
8
9
10
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 7
def belongs_to?
defined?(::Mongoid::Association) ? macro_mapping?(:belongs_to) : super
end
|
#foreign_type ⇒ Object
33
34
35
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 33
def foreign_type
@association.type
end
|
#habtm? ⇒ Boolean
20
21
22
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 20
def habtm?
defined?(::Mongoid::Association) ? macro_mapping?(:has_and_belongs_to_many) : super
end
|
#has_many? ⇒ Boolean
rubocop:disable Naming/PredicatePrefix
16
17
18
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 16
def has_many? defined?(::Mongoid::Association) ? macro_mapping?(:has_many) : super
end
|
#has_one? ⇒ Boolean
rubocop:disable Naming/PredicatePrefix
12
13
14
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 12
def has_one? defined?(::Mongoid::Association) ? macro_mapping?(:has_one) : super
end
|
#macro_mapping?(macro) ⇒ Boolean
53
54
55
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 53
def macro_mapping?(macro)
@association.is_a? ::Mongoid::Association::MACRO_MAPPING[macro]
end
|
#polymorphic? ⇒ Boolean
25
26
27
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 25
def polymorphic?
belongs_to? && @association.polymorphic?
end
|
#quoted_primary_key ⇒ Object
45
46
47
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 45
def quoted_primary_key
'_id'
end
|
#quoted_table_name ⇒ Object
41
42
43
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 41
def quoted_table_name
table_name
end
|
#table_name ⇒ Object
37
38
39
|
# File 'lib/active_scaffold/data_structures/association/mongoid.rb', line 37
def table_name
@association.klass.collection.name
end
|