Class: Anima Private
- Inherits:
-
Module
- Object
- Module
- Anima
- Includes:
- Adamantium::Flat
- Defined in:
- lib/anima.rb,
lib/anima/error.rb,
lib/anima/attribute.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Main library namespace and mixin
Defined Under Namespace
Modules: InstanceMethods Classes: Attribute, Error
Instance Attribute Summary collapse
-
#attributes ⇒ AttributeSet
readonly
private
Return names.
Instance Method Summary collapse
-
#add(*names) ⇒ Anima
private
Return new anima with attributes added.
-
#attribute_names ⇒ Enumerable<Symbol>
private
Return attribute names.
-
#attributes_hash(object) ⇒ Hash
private
Return attributes hash for instance.
-
#initialize(*names) ⇒ undefined
constructor
private
Initialize object.
-
#initialize_instance(object, attribute_hash) ⇒ self
private
Initialize instance.
-
#remove(*names) ⇒ Anima
private
Return new anima with attributes removed.
Constructor Details
#initialize(*names) ⇒ undefined
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.
Initialize object
18 19 20 |
# File 'lib/anima.rb', line 18 def initialize(*names) @attributes = names.uniq.map(&Attribute.method(:new)).freeze end |
Instance Attribute Details
#attributes ⇒ AttributeSet (readonly)
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.
Return names
13 14 15 |
# File 'lib/anima.rb', line 13 def attributes @attributes end |
Instance Method Details
#add(*names) ⇒ Anima
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.
Return new anima with attributes added
30 31 32 |
# File 'lib/anima.rb', line 30 def add(*names) new(attribute_names + names) end |
#attribute_names ⇒ Enumerable<Symbol>
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.
Return attribute names
60 61 62 |
# File 'lib/anima.rb', line 60 def attribute_names attributes.map(&:name) end |
#attributes_hash(object) ⇒ Hash
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.
Return attributes hash for instance
51 52 53 54 55 |
# File 'lib/anima.rb', line 51 def attributes_hash(object) attributes.each_with_object({}) do |attribute, attributes_hash| attributes_hash[attribute.name] = attribute.get(object) end end |
#initialize_instance(object, attribute_hash) ⇒ self
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.
Initialize instance
72 73 74 75 76 77 78 |
# File 'lib/anima.rb', line 72 def initialize_instance(object, attribute_hash) assert_known_attributes(object.class, attribute_hash) attributes.each do |attribute| attribute.load(object, attribute_hash) end self end |
#remove(*names) ⇒ Anima
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.
Return new anima with attributes removed
42 43 44 |
# File 'lib/anima.rb', line 42 def remove(*names) new(attribute_names - names) end |