Class: ROM::Components::View
Instance Attribute Summary collapse
-
#relation_block ⇒ Proc
readonly
private
Block used for view method definition.
-
#relation_id ⇒ Symbol
readonly
private
Relation runtime identifier.
Instance Method Summary collapse
- #build ⇒ ROM::Relation private
- #define(constant) ⇒ Symbol private
Instance Attribute Details
#relation_block ⇒ Proc (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.
Returns Block used for view method definition.
17 |
# File 'lib/rom/components/view.rb', line 17 option :relation_block |
#relation_id ⇒ Symbol (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.
Returns Relation runtime identifier.
12 |
# File 'lib/rom/components/view.rb', line 12 option :relation_id |
Instance Method Details
#build ⇒ ROM::Relation
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.
22 23 24 |
# File 'lib/rom/components/view.rb', line 22 def build registry.relations[relation_id].public_send(config.id) end |
#define(constant) ⇒ Symbol
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rom/components/view.rb', line 29 def define(constant) _name = config.id _relation_block = relation_block if relation_block&.arity&.positive? constant.class_eval do auto_curry_guard do define_method(_name, &_relation_block) auto_curry(_name) do schemas[_name].(self) end end end else constant.class_eval do define_method(_name) do schemas[_name].(instance_eval(&_relation_block)) end end end _name end |