Class: Hanami::Model::Association Private
- Inherits:
-
Object
- Object
- Hanami::Model::Association
- Defined in:
- lib/hanami/model/association.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.
Association factory
Class Method Summary collapse
-
.build(repository, target, subject) ⇒ Object
private
Instantiate an association.
-
.lookup(association) ⇒ Object
private
Translate ROM SQL associations into Hanami::Model associations.
Class Method Details
.build(repository, target, subject) ⇒ 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.
Instantiate an association
16 17 18 19 |
# File 'lib/hanami/model/association.rb', line 16 def self.build(repository, target, subject) lookup(repository.root.associations[target]) .new(repository, repository.root.name.to_sym, target, subject) end |
.lookup(association) ⇒ 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.
Translate ROM SQL associations into Hanami::Model associations
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hanami/model/association.rb', line 25 def self.lookup(association) case association when ROM::SQL::Association::OneToMany Associations::HasMany when ROM::SQL::Association::ManyToOne Associations::BelongsTo else raise "Unsupported association: #{association}" end end |