Skip to content

Instantly share code, notes, and snippets.

@we4tech we4tech/Gemfile
Created Feb 21, 2019

Embed
What would you like to do?
# frozen_string_literal: true
require 'dry-container'
module DiTalk
module Services
class ClassicGreeter
def greet(name)
"Hello #{name}"
end
end
class NewEraGreeter
def greet(name)
"'s up, #{name}"
end
end
class Container
extend Dry::Container::Mixin
register(:greeter, memoize: true) do
ClassicGreeter.new
end
end
end
module Controllers
class Greeter
def initialize(container)
@greeter = container.resolve(:greeter)
end
def call(env)
[200, {}, [@greeter.greet('WeWork')]]
end
end
end
end
# frozen_string_literal: true
require_relative 'app'
container = DiTalk::Services::Container
run DiTalk::Controllers::Greeter.new(container)
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'rack'
gem 'dry-container'
gem 'minitest'
gem 'mocha'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.