JoshCheek/deject — pull request #1 by sdegutis (2012-04-12 18:59:11+00:00)
Title: API change

Changes:

- Added "foo=" methods
- Removed chaining "with_foo" methods
- Removed lazily-evaluated-block feature when overriding dependency at instance level
- Removed default-dependency-omission feature
- Removed method to override multiple dependencies simultaneously
- Greatly simplified implementation

Compare https://github.com/sdegutis/deject/blob/master/lib/deject/deject.rb to https://github.com/JoshCheek/deject/blob/master/lib/deject/functional.rb or https://github.com/JoshCheek/deject/blob/master/lib/deject/object_oriented.rb to more clearly see the last point.

Rationale:

Using with_foo to specify dependencies at the instance level allows chaining methods but usually makes lines too long and hard to read, and it becomes easier to miss injected dependencies when reading through and editing tests. Plus, in practice, chained instantiations with actions are usually split out into multiple lines in production code and this practice, when applied to writing tests as well, would solve the aforementioned problem. Thus, an attr_writer-style technique of overriding dependencies at the instance level is more natural to the problem domain. It also simplifies the API that any clients of this gem need to learn.

Because of the nature of the aforementioned solution, there is no utility anymore for a specific feature to override multiple dependencies simultaneously, so that feature has also been removed. It also simplifies the API that any clients of this gem need to learn.

When overriding a dependency at the instance level, there is no conceivable real-world use-case for needing to provide a lazily-evaluated new dependency. Setting it with an attr_writer-style method suffices in all actual situations. It also simplifies the API that any clients of this gem need to learn.

The ability to omit a default dependency can be easily emulated by the client of this gem manually raising an exception within the block for a default dependency. It also simplifies the API that any clients of this gem need to learn.