Class: Hashing::IvarCollection
- Inherits:
-
Object
- Object
- Hashing::IvarCollection
- Extended by:
- Forwardable
- Defined in:
- lib/hashing/ivar_collection.rb
Overview
Instance Method Summary collapse
- #from_hash(value) ⇒ Object
-
#initialize(collection_holder_ivar, type) ⇒ IvarCollection
constructor
A new instance of IvarCollection.
- #to_h(value) ⇒ Object
Constructor Details
#initialize(collection_holder_ivar, type) ⇒ IvarCollection
Returns a new instance of IvarCollection.
8 9 10 11 |
# File 'lib/hashing/ivar_collection.rb', line 8 def initialize(collection_holder_ivar, type) @holder = collection_holder_ivar @type = type end |
Instance Method Details
#from_hash(value) ⇒ Object
19 20 21 |
# File 'lib/hashing/ivar_collection.rb', line 19 def from_hash(value) @holder.from_hash value.map { |item| @type.from_hash item } end |
#to_h(value) ⇒ Object
13 14 15 16 17 |
# File 'lib/hashing/ivar_collection.rb', line 13 def to_h(value) @holder.to_h value.map { |item| item.respond_to?(:to_h) ? item.to_h : item } end |