Class: ROM::Factory::Builder Private
- Inherits:
-
Object
- Object
- ROM::Factory::Builder
- Extended by:
- Initializer
- Includes:
- Dry::Core::Constants
- Defined in:
- lib/rom/factory/builder.rb,
lib/rom/factory/builder/persistable.rb
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.
Defined Under Namespace
Classes: Persistable
Instance Attribute Summary collapse
- #attributes ⇒ ROM::Factory::Attributes readonly
- #relation ⇒ Object readonly private
- #traits ⇒ Hash readonly
Instance Method Summary collapse
- #persistable(struct_namespace = ROM::Struct) ⇒ Object private
- #struct(*traits, **attrs) ⇒ Object (also: #create) private
- #struct_namespace(namespace) ⇒ Object private
- #tuple(*traits, **attrs) ⇒ Object private
- #tuple_evaluator ⇒ Object private
- #validate_keys(traits, tuple) ⇒ Object private
Instance Attribute Details
#attributes ⇒ ROM::Factory::Attributes (readonly)
19 |
# File 'lib/rom/factory/builder.rb', line 19 param :attributes |
#relation ⇒ 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.
27 |
# File 'lib/rom/factory/builder.rb', line 27 option :relation, reader: false |
#traits ⇒ Hash (readonly)
23 |
# File 'lib/rom/factory/builder.rb', line 23 param :traits, default: -> { EMPTY_HASH } |
Instance Method Details
#persistable(struct_namespace = ROM::Struct) ⇒ 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.
47 48 49 |
# File 'lib/rom/factory/builder.rb', line 47 def persistable(struct_namespace = ROM::Struct) Persistable.new(self, relation.struct_namespace(struct_namespace)) end |
#struct(*traits, **attrs) ⇒ Object Also known as: create
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.
35 36 37 38 |
# File 'lib/rom/factory/builder.rb', line 35 def struct(*traits, **attrs) validate_keys(traits, attrs) tuple_evaluator.struct(*traits, attrs) end |
#struct_namespace(namespace) ⇒ 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.
42 43 44 |
# File 'lib/rom/factory/builder.rb', line 42 def struct_namespace(namespace) with(relation: relation.struct_namespace(namespace)) end |
#tuple(*traits, **attrs) ⇒ 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.
30 31 32 |
# File 'lib/rom/factory/builder.rb', line 30 def tuple(*traits, **attrs) tuple_evaluator.defaults(traits, attrs) end |
#tuple_evaluator ⇒ 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/rom/factory/builder.rb', line 52 def tuple_evaluator @__tuple_evaluator__ ||= TupleEvaluator.new(attributes, [:relation], traits) end |
#validate_keys(traits, tuple) ⇒ 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.
62 63 64 65 66 67 68 |
# File 'lib/rom/factory/builder.rb', line 62 def validate_keys(traits, tuple) schema_keys = relation.schema.attributes.map(&:name) assoc_keys = tuple_evaluator.assoc_names(traits) unknown_keys = tuple.keys - schema_keys - assoc_keys raise UnknownFactoryAttributes, unknown_keys unless unknown_keys.empty? end |