Class: Cuprum::Collections::Errors::AbstractFindError
- Inherits:
-
Error
- Object
- Error
- Cuprum::Collections::Errors::AbstractFindError
- Defined in:
- lib/cuprum/collections/errors/abstract_find_error.rb
Overview
Abstract base class for failed query errors.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attribute_name ⇒ String
readonly
The name of the queried attribute, if any.
-
#attribute_value ⇒ Object
readonly
The value of the queried attribute, if any.
-
#attributes ⇒ Hash<String=>Object>
readonly
The queried attributes.
-
#collection_name ⇒ String
readonly
The name of the collection.
-
#query ⇒ Cuprum::Collections::Query
readonly
The performed query, if any.
Instance Method Summary collapse
-
#details ⇒ Array<Array>
The details of the query, in query criteria format.
-
#initialize(collection_name:, **options) ⇒ AbstractFindError
constructor
A new instance of AbstractFindError.
-
#primary_key? ⇒ true, false
Indicates that the queried attribute is the primary key for the collection.
Constructor Details
#initialize(attribute_name: , attribute_value: , collection_name: , primary_key: false) ⇒ AbstractFindError #initialize(attributes: , collection_name: ) ⇒ AbstractFindError #initialize(query: , collection_name: ) ⇒ AbstractFindError
Returns a new instance of AbstractFindError.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 31 def initialize(collection_name:, **) # rubocop:disable Metrics/MethodLength @collection_name = collection_name @primary_key = false (**) super( attribute_name: attribute_name, attribute_value: attribute_value, attributes: attributes, collection_name: collection_name, message: , query: query&.criteria ) end |
Instance Attribute Details
#attribute_name ⇒ String (readonly)
Returns the name of the queried attribute, if any.
48 49 50 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 48 def attribute_name @attribute_name end |
#attribute_value ⇒ Object (readonly)
Returns the value of the queried attribute, if any.
51 52 53 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 51 def attribute_value @attribute_value end |
#attributes ⇒ Hash<String=>Object> (readonly)
Returns The queried attributes.
54 55 56 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 54 def attributes @attributes end |
#collection_name ⇒ String (readonly)
Returns the name of the collection.
57 58 59 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 57 def collection_name @collection_name end |
#query ⇒ Cuprum::Collections::Query (readonly)
Returns the performed query, if any.
60 61 62 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 60 def query @query end |
Instance Method Details
#details ⇒ Array<Array>
Returns the details of the query, in query criteria format.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 63 def details if attribute_name [[attribute_name, :equal, attribute_value]] elsif attributes attributes .map { |attr_name, attr_value| [attr_name, :equal, attr_value] } elsif query query.criteria end end |
#primary_key? ⇒ true, false
Returns indicates that the queried attribute is the primary key for the collection.
76 77 78 |
# File 'lib/cuprum/collections/errors/abstract_find_error.rb', line 76 def primary_key? @primary_key end |