joshuaflanagan/ruse — pull request #7 by ntl (2014-03-15 15:44:45+00:00)
Title: Alter Ruse::Injector#clone to deep copy config

In ruby, Object#clone creates a shallow copy of an object; instance
variables are copied, but not the objects they reference. This means
that when you send #clone to an Injector, previously they would share
the same configuration hash.

This change is intended to support building child injectors, but using
plain ruby semantics (Object#clone).

Example use case in rails:

```ruby
class User
attr :repository, :first_name, :last_name

def initialize(repository, first_name, last_name)
# set values
end
end

class ApplicationController < ActionController::Base
before_filter :create_injector

private

def create_injector
@injector = Ruse.create_injector(repository: MyRepository)
end
end

class UsersController < ApplicationController
def create
child_injector = @injector.clone
child_injector.configure(
values: {
first_name: params[:first_name],
last_name: params[:last_name],
}
)
child_injector.get(:user)
end
end
```

In the above example, first_name and last_name may be coming from,
say, a

tag, through a params hash.