Class: ActiveScaffold::DataStructures::Association::ActiveRecord
- Inherits:
-
Abstract
- Object
- Abstract
- ActiveScaffold::DataStructures::Association::ActiveRecord
show all
- Defined in:
- lib/active_scaffold/data_structures/association/active_record.rb
Instance Attribute Summary
Attributes inherited from Abstract
#reverse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Abstract
#allow_join?, #belongs_to?, #collection?, #habtm?, #has_many?, #has_one?, #initialize, #inverse_for?, #klass, #polymorphic?, #reverse_association, #singular?, #through_collection?, #through_singular?
Class Method Details
.reflect_on_all_associations(klass) ⇒ Object
3
4
5
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 3
def self.reflect_on_all_associations(klass)
klass.reflect_on_all_associations
end
|
Instance Method Details
41
42
43
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 41
def as
@association.options[:as]
end
|
#counter_cache ⇒ Object
37
38
39
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 37
def counter_cache
@association.options[:counter_cache]
end
|
#counter_cache_hack? ⇒ Boolean
66
67
68
69
70
71
72
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 66
def counter_cache_hack?
if has_many?
Rails.version < '5.0' && as
elsif belongs_to?
counter_cache && (Rails.version >= '5.0' || !polymorphic?)
end
end
|
#dependent ⇒ Object
45
46
47
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 45
def dependent
@association.options[:dependent]
end
|
50
51
52
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 50
def inverse
@association.inverse_of&.name
end
|
#inverse_klass ⇒ Object
29
30
31
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 29
def inverse_klass
@association.active_record
end
|
#primary_key ⇒ Object
33
34
35
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 33
def primary_key
@association.options[:primary_key]
end
|
#quoted_primary_key ⇒ Object
58
59
60
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 58
def quoted_primary_key
@association.klass.quoted_primary_key
end
|
#quoted_table_name ⇒ Object
54
55
56
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 54
def quoted_table_name
@association.klass.quoted_table_name
end
|
#readonly? ⇒ Boolean
13
14
15
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 13
def readonly?
scope_values[:readonly]
end
|
#respond_to_target? ⇒ Boolean
62
63
64
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 62
def respond_to_target?
true
end
|
25
26
27
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 25
def scope
@association.scope
end
|
#source_reflection ⇒ Object
21
22
23
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 21
def source_reflection
@association.source_reflection if through?
end
|
#through? ⇒ Boolean
9
10
11
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 9
def through?
@association.options[:through].present?
end
|
#through_reflection ⇒ Object
17
18
19
|
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 17
def through_reflection
@association.through_reflection if through?
end
|