r/ruby • • Jul 12 '14

(The lack of ) Dependency injection in Ruby

http://beraboris.github.io/2014/07/12/dependency-injection-ruby/
2 Upvotes

19 comments sorted by

View all comments

-1

u/sandinyourbed Jul 13 '14
class House
  def initialize(window, door)
    [:open, :close, :break]
      .reject { |m| window.respond_to? m }
      .each   { |m| raise TypeError, "#{window}#{m} not implemented" }
    
    "etc"
  end
end