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
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
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.
30 31 32 33 34 35 36 37 38 |
# File 'lib/stannum/entities/attributes.rb', line 30 def attribute(attr_name, attr_type, **) attributes.define_attribute( name: attr_name, type: attr_type, options: ) attr_name.intern end |
#attributes ⇒ Stannum::Schema
Returns The attributes Schema object for the Entity.
41 42 43 |
# File 'lib/stannum/entities/attributes.rb', line 41 def attributes self::Attributes end |