Module: Cuprum::Collections::Adaptable::Query
- Defined in:
- lib/cuprum/collections/adaptable/query.rb
Overview
Mixin for adaptable collection Query implementations.
Defined Under Namespace
Classes: AbstractQueryError, InvalidDataError
Instance Attribute Summary collapse
-
#adapter ⇒ Cuprum::Collections::Adapter
readonly
The collection adapter.
Instance Method Summary collapse
-
#convert(native) ⇒ Object
Converts a native data representation to the adapter entity format.
- #initialize(adapter:) ⇒ Object
Instance Attribute Details
#adapter ⇒ Cuprum::Collections::Adapter (readonly)
Returns the collection adapter.
23 24 25 |
# File 'lib/cuprum/collections/adaptable/query.rb', line 23 def adapter @adapter end |
Instance Method Details
#convert(native) ⇒ Object
Converts a native data representation to the adapter entity format.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cuprum/collections/adaptable/query.rb', line 31 def convert(native) attributes = convert_native_to_attributes(native) result = adapter.build(attributes:) return result.value if result.success? # This is an internal data error, not resolvable by the user. raise InvalidDataError, (attributes:, error: result.error, native:) end |
#initialize(adapter:) ⇒ Object
16 17 18 19 20 |
# File 'lib/cuprum/collections/adaptable/query.rb', line 16 def initialize(*, adapter:, **) super(*, **) @adapter = adapter end |