Module: Lean::Attributes::Basic
- Defined in:
- lib/lean-attributes/attributes.rb
Overview
Includes basic methods for defining attributes without polluting the inclusive class with coercion or initialization methods. You may mean to use Lean::Attributes.
Class Method Summary collapse
-
.included(base) ⇒ Object
private
Adds ‘.attribute` definition only.
Instance Method Summary collapse
-
#attributes ⇒ Hash
Returns a hash containing defined attribute names and their values.
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds ‘.attribute` definition only
29 30 31 32 33 |
# File 'lib/lean-attributes/attributes.rb', line 29 def self.included(base) base.class_eval do extend ClassMethods end end |
Instance Method Details
#attributes ⇒ Hash
Returns a hash containing defined attribute names and their values.
41 42 43 44 45 46 |
# File 'lib/lean-attributes/attributes.rb', line 41 def attributes @attributes ||= self.class.defined_attributes.each_with_object({}) do |attr, memo| memo[attr] = send(attr) end end |