require 'configure'; Configure.activate
The configure library will use .build
as the factory method by default. To override, supply factory_method
to Configure.activate
:
require 'configure'; Configure.activate factory_method: :create
class SomeClass
configure :some_attr_name
end
receiver = OpenStruct.new
SomeClass.configure receiver
# Returns instance of SomeClass
receiver.some_attr_name
receiver = OpenStruct.new
SomeClass.configure receiver, attr_name: :other_attr_name
# Returns instance of SomeClass
receiver.other_attr_name