Module: Stannum::Entities::Attributes::ClassMethods
- Parent Namespace
- Stannum::Entities::Attributes
- Defined In
- lib/stannum/entities/attributes.rb
Table Of Contents
Overview
Class methods to extend the class when including Attributes.
Back To Top
Instance Methods
#attribute(attr_name, attr_type, **options) => Symbol
Also known as:
define_attribute
Defines an attribute on the entity.
When an attribute is defined, each of the following steps is executed:
- Adds the attribute to ::Attributes and the .attributes class method.
- Adds the attribute to #attributes and the associated methods, such as
#assign_attributes, #[] and #[]=.
- Defines reader and writer methods.
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.
Returns
Back To Top
Back to
Documentation |
Versions |
0.4 |
Reference
|
Stannum
|
Stannum::Entities
|
Stannum::Entities::Attributes