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?, #cache_count?, #collection?, #counter_cache, #counter_cache_hack?, #habtm?, #has_many?, #has_one?, #initialize, #inverse_for?, #klass, #nested?, #polymorphic?, #primary_key, #reverse_association, #scope, #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



5
6
7
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 5

def self.reflect_on_all_associations(klass)
  klass.reflect_on_all_associations
end

Instance Method Details

#asObject



31
32
33
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 31

def as
  @association.options[:as]
end

#dependentObject



35
36
37
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 35

def dependent
  @association.options[:dependent]
end

#inverseObject

name of inverse



40
41
42
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 40

def inverse
  @association.inverse_of&.name
end

#inverse_klassObject



27
28
29
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 27

def inverse_klass
  @association.active_record
end

#quoted_primary_keyObject



48
49
50
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 48

def quoted_primary_key
  @association.klass.quoted_primary_key
end

#quoted_table_nameObject



44
45
46
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 44

def quoted_table_name
  @association.klass.quoted_table_name
end

#readonly?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 15

def readonly?
  scope_values[:readonly]
end

#respond_to_target?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 52

def respond_to_target?
  true
end

#source_reflectionObject



23
24
25
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 23

def source_reflection
  @association.source_reflection if through?
end

#through?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 11

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

#through_reflectionObject



19
20
21
# File 'lib/active_scaffold/data_structures/association/active_record.rb', line 19

def through_reflection
  @association.through_reflection if through?
end