0

I am learning about Dependency Injection, which from my understanding is simply a means of managing dependencies and decoupling dependencies between classes and so fourth.

According to Anthony Ferrara one way to achieve dependency injection is to use a dependency injection container (DIC). DIC's do the following:

1) List all dependencies needed

2) Have logic to instantiate dependencies

My question is this: Is Ruby on Rails Gemfile a DIC?

chopper draw lion4
  • 12,401
  • 13
  • 53
  • 100

1 Answers1

1

I guess you've confused yourself with dependency manager and dependency injection. Both are two different things. Checkout this question about Gemfile.

To be more clear, Gemfile is used by bundler. So, Ruby on Rails or any other gem has nothing to with Gemfile. Bundler is just the default gem manager for Rails, though it can be used with any Ruby project as it has no dependency on framework.

Read more on how does bundler bundle, how bundler require gems, and this railscast on bundler.

While, a dependency injection is a software design pattern that implements inversion of control and allows a program design to follow the dependency inversion principle. The term was coined by Martin Fowler. An injection is the passing of a dependency (a service) to a dependent object (a client).

Community
  • 1
  • 1
Surya
  • 15,703
  • 3
  • 51
  • 74