Skip to content

Instantly share code, notes, and snippets.

@alexbartlow
Last active May 31, 2016 15:21
Show Gist options
  • Save alexbartlow/4f5908e5eefa3ebdd1b3ffc01ec4e327 to your computer and use it in GitHub Desktop.
Save alexbartlow/4f5908e5eefa3ebdd1b3ffc01ec4e327 to your computer and use it in GitHub Desktop.
class MyNewAwesomeClass
DEPENDENCIES = {
logger: -> { Rails.logger },
logic: -> { MyBusinessLogic.new },
service: -> { MyServiceClass }
}
attr_accessor :dependencies
def initialize(deps={})
@dependencies = DEPENDENCIES.clone.merge(deps)
end
def logger
@dependencies.fetch(:logger).call
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment