Class: ActiveScaffold::DataStructures::Association::ActiveRecord

Inherits:
Abstract
  • Object
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?, #counter_cache, #habtm?, #has_many?, #has_one?, #initialize, #inverse_for?, #klass, #polymorphic?, #primary_key, #reverse_association, #singular?, #through_collection?, #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
# 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

#asObject



33
34
35
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 33

def as
  @association.options[:as]
end

#counter_cache_hack?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 58

def counter_cache_hack?
  belongs_to? && counter_cache && Rails.version < '6.0'
end

#dependentObject



37
38
39
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 37

def dependent
  @association.options[:dependent]
end

#inverseObject

name of inverse



42
43
44
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 42

def inverse
  @association.inverse_of&.name
end

#inverse_klassObject



29
30
31
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 29

def inverse_klass
  @association.active_record
end

#quoted_primary_keyObject



50
51
52
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 50

def quoted_primary_key
  @association.klass.quoted_primary_key
end

#quoted_table_nameObject



46
47
48
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 46

def quoted_table_name
  @association.klass.quoted_table_name
end

#readonly?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


54
55
56
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 54

def respond_to_target?
  true
end

#scopeObject



25
26
27
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 25

def scope
  @association.scope
end

#source_reflectionObject



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

Returns:

  • (Boolean)


9
10
11
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 9

def through?
  @association.options[:through].present?
end

#through_reflectionObject



17
18
19
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 17

def through_reflection
  @association.through_reflection if through?
end