Created
November 13, 2023 19:06
-
-
Save timriley/27b8aa4c1e805dc6acb68a2b836252b8 to your computer and use it in GitHub Desktop.
Hanami deps demo with a view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Rubyconf2023 | |
module Views | |
module Posts | |
class Index < Rubyconf2023::View | |
include Deps["repos.post_repo"] | |
# the below is generated courtesy of dry-auto_inject (which hanami configures to work with | |
# its app/slice containers) | |
# def self.new(post_repo: nil) | |
# post_repo ||= Rubyconf2023::Container["repos.post_repo"] | |
# super(post_repo:) | |
# end | |
# attr_reader :post_repo | |
# def initialize(post_repo:) | |
# super() | |
# @post_repo = post_repo | |
# end | |
expose :posts do | |
post_repo.all | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment