class ActiveRecordAnalyzer::Reflector::HasMany
Public Class Methods
new(klass)
click to toggle source
# File lib/active_record_analyzer/reflector/has_many.rb, line 2 def initialize(klass) @klass = klass end
Public Instance Methods
attribute_type()
click to toggle source
# File lib/active_record_analyzer/reflector/has_many.rb, line 10 def attribute_type @attribute_type ||= ActiveRecordAnalyzer::Attribute::HasMany end
attributes()
click to toggle source
This returns foreign_keys and association names (ex: :company_id and :company).
# File lib/active_record_analyzer/reflector/has_many.rb, line 15 def attributes @attributes ||= has_many_associations.map { |assoc| assoc.name } end
has_attribute?(attribute)
click to toggle source
# File lib/active_record_analyzer/reflector/has_many.rb, line 6 def has_attribute?(attribute) attributes.include?(attribute.to_sym) end
Private Instance Methods
has_many_associations()
click to toggle source
# File lib/active_record_analyzer/reflector/has_many.rb, line 21 def has_many_associations @belongs_to_associations ||= begin @klass.reflect_on_all_associations.select do |assoc| assoc.is_a?(ActiveRecord::Reflection::HasManyReflection) end end end