Module: Realm::Mixins::DependencyInjection::ClassMethods
- Defined in:
- lib/realm/mixins/dependency_injection.rb
Instance Method Summary collapse
- #dependencies ⇒ Object
- #inject(*dependables, **options) ⇒ Object
- #new(*args, **kwargs, &block) ⇒ Object
Instance Method Details
#dependencies ⇒ Object
25 26 27 |
# File 'lib/realm/mixins/dependency_injection.rb', line 25 def dependencies deps.freeze end |
#inject(*dependables, **options) ⇒ Object
21 22 23 |
# File 'lib/realm/mixins/dependency_injection.rb', line 21 def inject(*dependables, **) deps.concat(dependables.map { |d| Dependency.new(d, **) }) end |
#new(*args, **kwargs, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/realm/mixins/dependency_injection.rb', line 13 def new(*args, **kwargs, &block) instance = allocate deps.each { |d| define_dependency_method(instance, kwargs, d) } kwargs_without_dependencies = kwargs.reject { |k, _| deps.any? { |d| d.name == k } } instance.send(:initialize, *args, **kwargs_without_dependencies, &block) instance end |