module Lasershark::CommonContext::ClassMethods
Public Instance Methods
build(context = {})
click to toggle source
Internal: Initialize an Interactor::Context or preserve an existing one. If the argument given is an Interactor::Context, the argument is returned. Otherwise, a new Interactor::Context is initialized from the provided hash.
The “build” method is used during interactor initialization.
context - A Hash whose key/value pairs are used in initializing a new
Interactor::Context object. If an existing Interactor::Context is given, it is simply returned. (default: {})
Examples
context = Interactor::Context.build(foo: "bar") # => #<Interactor::Context foo="bar"> context.object_id # => 2170969340 context = Interactor::Context.build(context) # => #<Interactor::Context foo="bar"> context.object_id # => 2170969340
Returns the Interactor::Context.
# File lib/lasershark/common_context.rb, line 27 def build(context = {}) self === context ? context : new(context) end