Class: ObjectForge::Molds::WrappedMold

Inherits:
Object
  • Object
show all
Defined in:
lib/object_forge/molds/wrapped_mold.rb

Overview

Mold that wraps a mold class.

Wrapping a mold class is useful when its #call is stateful, making it unsafe to use multiple times or in shared environments.

Since:

  • 0.2.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrapped_mold) ⇒ WrappedMold

Returns a new instance of WrappedMold.

Parameters:

  • wrapped_mold (Class)

    class with #call method

Since:

  • 0.2.0



17
18
19
# File 'lib/object_forge/molds/wrapped_mold.rb', line 17

def initialize(wrapped_mold)
  @wrapped_mold = wrapped_mold
end

Instance Attribute Details

#wrapped_moldClass (readonly)

Returns wrapped mold class.

Returns:

  • (Class)

    wrapped mold class

Since:

  • 0.2.0



14
15
16
# File 'lib/object_forge/molds/wrapped_mold.rb', line 14

def wrapped_mold
  @wrapped_mold
end

Instance Method Details

#call(...) ⇒ Any

Instantiate #wrapped_mold and call it.

Returns:

  • (Any)

    result of wrapped_mold.new.call(…)

Since:

  • 0.2.0



25
26
27
# File 'lib/object_forge/molds/wrapped_mold.rb', line 25

def call(...)
  wrapped_mold.new.call(...)
end