Class: Cuprum::Collections::CollectionCommand
- Inherits:
-
Cuprum::Command
- Object
- Cuprum::Command
- Cuprum::Collections::CollectionCommand
- Includes:
- ParameterValidation
- Defined in:
- lib/cuprum/collections/collection_command.rb
Overview
Abstract base class for commands implementing collection actions.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#collection ⇒ Cuprum::Collections::Collection
readonly
The collection to which the command belongs.
Instance Method Summary collapse
-
#initialize(collection:) ⇒ CollectionCommand
constructor
A new instance of CollectionCommand.
-
#name ⇒ String
(also: #collection_name)
The name of the relation.
-
#primary_key_name ⇒ String
The name of the primary key attribute.
-
#primary_key_type ⇒ Class, Stannum::Constraint
The type of the primary key attribute.
-
#query ⇒ Object
A new Query instance, used for querying against the collection data.
-
#singular_name ⇒ String
(also: #member_name)
The name of an entity in the collection.
Constructor Details
#initialize(collection:) ⇒ CollectionCommand
Returns a new instance of CollectionCommand.
15 16 17 18 19 |
# File 'lib/cuprum/collections/collection_command.rb', line 15 def initialize(collection:) super() @collection = collection end |
Instance Attribute Details
#collection ⇒ Cuprum::Collections::Collection (readonly)
Returns the collection to which the command belongs.
23 24 25 |
# File 'lib/cuprum/collections/collection_command.rb', line 23 def collection @collection end |
Instance Method Details
#name ⇒ String Also known as: collection_name
Returns the name of the relation.
26 27 28 |
# File 'lib/cuprum/collections/collection_command.rb', line 26 def name @name ||= collection.name end |
#primary_key_name ⇒ String
Returns the name of the primary key attribute. Defaults to 'id'.
32 33 34 |
# File 'lib/cuprum/collections/collection_command.rb', line 32 def primary_key_name @primary_key_name ||= collection.primary_key_name end |
#primary_key_type ⇒ Class, Stannum::Constraint
Returns the type of the primary key attribute. Defaults to Integer.
38 39 40 |
# File 'lib/cuprum/collections/collection_command.rb', line 38 def primary_key_type @primary_key_type ||= collection.primary_key_type end |
#query ⇒ Object
A new Query instance, used for querying against the collection data.
45 46 47 |
# File 'lib/cuprum/collections/collection_command.rb', line 45 def query collection.query end |
#singular_name ⇒ String Also known as: member_name
Returns the name of an entity in the collection.
50 51 52 |
# File 'lib/cuprum/collections/collection_command.rb', line 50 def singular_name @singular_name ||= collection.singular_name end |