Module: Stannum::Entities::Attributes::ClassMethods
- Defined in:
- lib/stannum/entities/attributes.rb
Overview
Class methods to extend the class when including Attributes.
Instance Method Summary collapse
-
#attribute(attr_name, attr_type, **options) ⇒ Symbol
(also: #define_attribute)
Defines an attribute on the entity.
-
#attributes ⇒ Stannum::Schema
The attributes Schema object for the Entity.
Instance Method Details
#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.
31 32 33 34 35 36 37 38 39 |
# File 'lib/stannum/entities/attributes.rb', line 31 def attribute(attr_name, attr_type, **) attributes.define( name: attr_name, type: attr_type, options: ) attr_name.intern end |
#attributes ⇒ Stannum::Schema
Returns The attributes Schema object for the Entity.
43 44 45 |
# File 'lib/stannum/entities/attributes.rb', line 43 def attributes self::Attributes end |