Method: Hanami::Model::Associations::HasOne#initialize

Defined in:
lib/hanami/model/associations/has_one.rb

#initialize(repository, source, target, subject, scope = nil) ⇒ HasOne

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of HasOne.

Since:

  • 1.1.0



41
42
43
44
45
46
47
48
# File 'lib/hanami/model/associations/has_one.rb', line 41

def initialize(repository, source, target, subject, scope = nil)
  @repository = repository
  @source     = source
  @target     = target
  @subject    = subject.to_hash unless subject.nil?
  @scope      = scope || _build_scope
  freeze
end