Class: ActiveAny::Associations::BelongsToAssociation

Inherits:
Association
  • Object
show all
Defined in:
lib/active_any/associations/belongs_to_association.rb

Instance Attribute Summary

Attributes inherited from Association

#inversed, #loaded, #owner, #reflection, #target

Instance Method Summary collapse

Methods inherited from Association

#association_scope, #find_from_target?, #initialize, #klass, #load_target, #loaded!, #loaded?, #reload, #reset, #reset_scope, #scope, #set_inverse_instance, #target_scope

Constructor Details

This class inherits a constructor from ActiveAny::Associations::Association

Instance Method Details

#find_targetObject



16
17
18
# File 'lib/active_any/associations/belongs_to_association.rb', line 16

def find_target
  scope.first
end

#readerObject



6
7
8
9
10
# File 'lib/active_any/associations/belongs_to_association.rb', line 6

def reader
  reload unless loaded?

  target
end

#writer(_records) ⇒ Object

Raises:

  • (NotImplementedError.new)


12
13
14
# File 'lib/active_any/associations/belongs_to_association.rb', line 12

def writer(_records)
  raise NotImplementedError.new, 'writer is unimplemented'
end