Module: Stannum::Entities::PrimaryKey::ClassMethods
- Parent Namespace
- Stannum::Entities::PrimaryKey
- Defined In
- lib/stannum/entities/primary_key.rb
Table Of Contents
Overview
Class methods to extend the class when including PrimaryKey.
Back To Top
Instance Methods
#define_primary_key(attr_name, attr_type, **options) => Symbol
Defines a primary key attribute on the entity.
Parameters
- attr_name (String, Symbol) — The name of the attribute. Must be a
non-empty String or Symbol.
- attr_type (Class, String) — The type of the attribute. Must be a
Class or Module, or the name of a class or module.
- options (Hash) — Additional options for the attribute.
Options Hash (options)
- :default (Object) — The default value for the attribute.
Defaults to nil.
- :primary_key (Boolean) — true if the attribute represents
the primary key for the entity; otherwise false. Defaults to false.
Returns
- (Symbol) — The attribute name as a symbol.
See Also
Returns
Raises
#primary_key? => Boolean
Returns
- (Boolean) — true if the entity class defines a primary key;
otherwise false.
#primary_key_name => String, nil
Returns
- (String, nil) — the name of the primary key attribute, or nil if
the entity does not define a primary key.
#primary_key_type => Class, nil
Returns
- (Class, nil) — the type of the primary key attribute, or nil if
the entity does not define a primary key.
Back To Top
Back to
Documentation |
Versions |
0.4 |
Reference
|
Stannum
|
Stannum::Entities
|
Stannum::Entities::PrimaryKey