Class: Associationist::Associations::CollectionAssociation

Inherits:
ActiveRecord::Associations::HasManyAssociation
  • Object
show all
Defined in:
lib/associationist/associations/collection_association.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_writers(mixin, name) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/associationist/associations/collection_association.rb', line 31

def self.define_writers(mixin, name)
  mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
    def #{name}=(value)
      raise "Virtual associations are read-only."
    end
  CODE
end

Instance Method Details

#association_scopeObject



4
5
6
# File 'lib/associationist/associations/collection_association.rb', line 4

def association_scope
  @_association_scope ||= reflection.config.scope_proc.call(owner)
end

#find_target?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/associationist/associations/collection_association.rb', line 8

def find_target?
  !loaded?
end

#klassObject



16
17
18
# File 'lib/associationist/associations/collection_association.rb', line 16

def klass
  association_scope.klass
end

#null_scope?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/associationist/associations/collection_association.rb', line 12

def null_scope?
  false
end