Class: Hanami::Model::MappedRelation Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Hanami::Model::MappedRelation
- Defined in:
- lib/hanami/model/mapped_relation.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.
Mapped proxy for ROM relations.
It eliminates the need to use #as for repository queries
Constant Summary collapse
- MAPPER_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mapper name.
With ROM mapping there is a link between the entity class and a generic reference for it. Example:
BookRepository
referencesBook
as:entity
. :entity
Class Method Summary collapse
- .mapper_name ⇒ Object private
Instance Method Summary collapse
-
#[](attribute) ⇒ ROM::SQL::Attribute
private
Access low level relation’s attribute.
-
#initialize(relation) ⇒ MappedRelation
constructor
private
A new instance of MappedRelation.
Constructor Details
#initialize(relation) ⇒ MappedRelation
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 MappedRelation.
30 31 32 33 |
# File 'lib/hanami/model/mapped_relation.rb', line 30 def initialize(relation) @relation = relation super(relation.as(self.class.mapper_name)) end |
Class Method Details
.mapper_name ⇒ 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.
24 25 26 |
# File 'lib/hanami/model/mapped_relation.rb', line 24 def self.mapper_name MAPPER_NAME end |
Instance Method Details
#[](attribute) ⇒ ROM::SQL::Attribute
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.
Access low level relation’s attribute
54 55 56 57 58 |
# File 'lib/hanami/model/mapped_relation.rb', line 54 def [](attribute) @relation[attribute] rescue KeyError => exception raise UnknownAttributeError.new(exception.) end |