# CONTROLER class MyApp::InvoicesController def index input = { interval: params[:interval] } MyApp::GetInvoices.call(input) do |on| on.success do |result| # ... end on.failure(:invalid_attributes) do |result| # ... end end end end # USE-CASE class MyApp::GetInvoices < ::Micro::Case attribute :interval, cast: MyApp::DateRange def call! run_query(interval.from, interval.to) end end # CUSTOM TYPE class MyApp::DateRange # Ainda não tenho certeza dessa API, se é melhor retornar algum valor (Kind::Some) ou lançar uma exception def self.cast(input) raise "Must be a string" unless input.is_a?(String) date1, date2 = input.split(" - ") new(Time.new(date1), Time.new(date2)) end end