Class: ObjectForge::Molds::ArrayMold
- Inherits:
-
Object
- Object
- ObjectForge::Molds::ArrayMold
- Defined in:
- lib/object_forge/molds/array_mold.rb
Overview
Mold for constructing Arrays.
Instance Method Summary collapse
-
#call(forge_target:, attributes:, **_) ⇒ Array
Build a new array from attributes’ values.
Instance Method Details
#call(forge_target:, attributes:, **_) ⇒ Array
Build a new array from attributes’ values.
If forge_target is Array, result is built directly by calling attributes.values. If it is a different class, its .new method is called with the values array.
20 21 22 23 24 |
# File 'lib/object_forge/molds/array_mold.rb', line 20 def call(forge_target:, attributes:, **_) return attributes.values if Array == forge_target # rubocop:disable Style/YodaCondition forge_target.new(attributes.values) end |