Class: ROM::Mapping
- Inherits:
-
Object
- Object
- ROM::Mapping
- Includes:
- Adamantium::Flat
- Defined in:
- lib/rom/mapping.rb,
lib/rom/mapping/definition.rb
Overview
Builder DSL for ROM relations
Defined Under Namespace
Classes: Definition
Class Method Summary collapse
-
.build(environment, schema, &block) ⇒ Hash
Build ROM relations.
Instance Method Summary collapse
-
#initialize(environment, schema, &block) ⇒ undefined
constructor
private
Initialize a new mapping instance.
Constructor Details
#initialize(environment, schema, &block) ⇒ undefined
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.
Initialize a new mapping instance
46 47 48 49 50 |
# File 'lib/rom/mapping.rb', line 46 def initialize(environment, schema, &block) @environment = environment @schema = schema instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, &block) ⇒ Relation (private)
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.
Method missing hook
59 60 61 62 63 64 65 66 67 |
# File 'lib/rom/mapping.rb', line 59 def method_missing(name, *, &block) relation = schema[name] if relation build_relation(relation, &block) else super end end |
Class Method Details
.build(environment, schema, &block) ⇒ Hash
Build ROM relations
37 38 39 |
# File 'lib/rom/mapping.rb', line 37 def self.build(environment, schema, &block) new(environment, schema, &block) end |