- Add an
injected_methods(include_super = true)
instance and singleton helper method to track what dependency methods have been created. This method includes itself in the list of injected methods. The instance method will return both injected and static injected methods, while the singleton method will only return static injected methods.
-
Ruby 3.x made it an error to override a class variable in a parent class. There was a bug with
inject_static
where if a subclass was the first to call a static dependency, the class variable would only be set on that subclass (and children of that subsclass). If the injecting class then called the static dependency, it would override the already set child's class variable, which is now an error.class Parent include Interjectable inject_static(:boom) { "goats" } end class Child < Parent; end Child.boom # => sets Child's @@boom = "goats" Parent.boom # => sets Parent's @@boom = "goats" and *clear* Child's @@boom. Child.boom # => Error on Ruby 3.x because you are trying to read an overriden class variable.
Fix: always set the class variable on the class that called
inject_static
.
- Fix
test_inject
for sub-sub-classes.
- Fix visibility issue with
Module.define_method
for Ruby < 2.5.0.
- Fix typo in RSpec helper loading error message
- Add another RSpec helper
test_inject
to avoid needing a local variable for the setter block to reference. Again, see the README.md for usage.
- Calling
#inject
or#inject_static
multiple times is now an error. Use#test_inject
instead. - Add
#test_inject
rspec helper. See the README.md for usage.
- Clear previously set class variables an subsequent calls to
#inject_static
- Don't include
#inject
and#inject_static
as instance variables oninclude Interjectable
Small feature.
- Added
Interjectable#inject_static
for sharing values across multiple instances.
Small patch.
- Updated
Interjectable#inject
to only call dependencies once, including results with falsy values.
Initial release.
- Added
Interjectable#inject