Module: Wirer::Factory::ClassMixin
Overview
You can extend a Class instance directly with this if you want the class itself to be usable as a factory, exposing Wirer::Factory::Interface.
By default, new_from_dependencies will call new on the class with the hash of dependencies as the last argument (or merged into the last argument where this is already a Hash). If you don’t like this you may want to override the new_from_dependencies class method.
You’ll still probably want to override some of
constructor_dependencies, provides_features, setter_dependencies;
if you’d prefer to do this via a handy DSL, instead see See Wirer::Factory::ClassDSL.
Instance Method Summary collapse
Methods included from Interface
#constructor_dependencies, #curry_with_dependencies, #inject_dependency, #post_initialize, #provides_features, #setter_dependencies, #wrapped_with
Instance Method Details
#new_from_dependencies(dependencies, *other_args, &block_arg) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/wirer/factory/class_mixins.rb', line 21 def new_from_dependencies(dependencies, *other_args, &block_arg) if other_args.last.is_a?(Hash) hash_arg = other_args.pop other_args.push(hash_arg.merge(dependencies)) else other_args.push(dependencies) unless dependencies.empty? end new(*other_args, &block_arg) end |
#provides_class ⇒ Object
19 |
# File 'lib/wirer/factory/class_mixins.rb', line 19 def provides_class; self; end |