Class: Hanami::Model::Associations::BelongsTo Private
- Inherits:
-
Object
- Object
- Hanami::Model::Associations::BelongsTo
- Defined in:
- lib/hanami/model/associations/belongs_to.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Many-To-One association
Instance Attribute Summary collapse
- #repository ⇒ Object readonly private
- #scope ⇒ Object readonly private
- #source ⇒ Object readonly private
- #subject ⇒ Object readonly private
- #target ⇒ Object readonly private
Class Method Summary collapse
- .schema_type(entity) ⇒ Object private
Instance Method Summary collapse
-
#initialize(repository, source, target, subject, scope = nil) ⇒ BelongsTo
constructor
private
A new instance of BelongsTo.
- #one ⇒ Object private
Constructor Details
#initialize(repository, source, target, subject, scope = nil) ⇒ BelongsTo
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 BelongsTo.
41 42 43 44 45 46 47 48 |
# File 'lib/hanami/model/associations/belongs_to.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 |
Instance Attribute Details
#repository ⇒ Object (readonly)
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.
21 22 23 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 21 def repository @repository end |
#scope ⇒ Object (readonly)
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.
37 38 39 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 37 def scope @scope end |
#source ⇒ Object (readonly)
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.
25 26 27 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 25 def source @source end |
#subject ⇒ Object (readonly)
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.
33 34 35 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 33 def subject @subject end |
#target ⇒ Object (readonly)
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.
29 30 31 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 29 def target @target end |
Class Method Details
.schema_type(entity) ⇒ Object
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.
15 16 17 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 15 def self.schema_type(entity) Sql::Types::Schema::AssociationType.new(entity) end |
Instance Method Details
#one ⇒ Object
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.
52 53 54 |
# File 'lib/hanami/model/associations/belongs_to.rb', line 52 def one scope.one end |