Skip to content

Instantly share code, notes, and snippets.

@joaquimadraz
joaquimadraz / simple_use_case_example.rb
Created March 30, 2015 23:41
simple_use_case_example
module App
module UseCases
module Users
module AssignBadge
# REQUIRED CONTEXT:
# - id
# - badge_id
class Base < UseCase::Base
@joaquimadraz
joaquimadraz / use_case_invoice_example.rb
Created March 18, 2015 18:11
use_case_invoice_example
# USE CASE:
# As a user I want to finalize an Invoice and an email should be delivered to the customer.
class FinalizeInvoiceUseCase < UseCase::Base
depends FindInvoice, ValidateToFinalize, FinalizeInvoice, SendEmail
end
@joaquimadraz
joaquimadraz / simple_use_cases_folder.rb
Last active January 17, 2019 16:45
Simple use_cases folder example
|- app
| |- use_cases
| | |- users
| | | |- index
| | | | |-- base.rb
| | | | |-- parse_params.rb
| | | |- create
| | | | |-- base.rb
| | | | |-- parse_params.rb
| | | | |-- persist.rb
@joaquimadraz
joaquimadraz / gist:7213795
Created October 29, 2013 12:32
Remove rails warning
Remove WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Open ~/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpresponse.rb
goto line 205 and change it to:
if chunked? || @header['content-length'] || @status == 304 || @status == 204
Change the ruby version in the path to your version
bye bye warning
class Team
attr_accessor :name, :country
private_class_method :new
end
class Barcelona < Team
def initialize(name, country)
@name = name
@country = country
end