Skip to content

Instantly share code, notes, and snippets.

@pmyjavec
Last active December 16, 2015 16:58
Show Gist options
  • Save pmyjavec/5466564 to your computer and use it in GitHub Desktop.
Save pmyjavec/5466564 to your computer and use it in GitHub Desktop.
### Problem, rigid dependency injection ###
class Demo
def initialize
@instancev = Something.new
end
def method_1
do_that
@instancev.something
end
def method_2
filter_something
@instancev.orother
end
end
### Solution ###
class Demo
def something
Something
end
def will_use_something
s = something.new
s.awesome_stuff
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment