Sha256: db676fbaa99adb8be6c22da773571fdad3784de338f57960036110aa7ab8e1b0

Contents?: true

Size: 376 Bytes

Versions: 1

Compression:

Stored size: 376 Bytes

Contents

#
# Extension for Object to provide dependency injection capability.
#
class Object
  # Define a new method and instance variable named as +object_name+ parameter.
  def self.inject(object_name)
    instance_eval do
      send(:define_method, object_name) do
        instance_variable_set("@#{object_name}", Syringe::Container.default[object_name])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
syringe-0.0.1.pre lib/syringe/extension.rb