Last active
December 16, 2015 06:19
-
-
Save jamiehodge/5390925 to your computer and use it in GitHub Desktop.
What am I?
This file contains 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
# What am I? A controller? A router? | |
class Foo < Sinatra::Base | |
set :bar, Baz | |
def self.both | |
# aren't a composite object in denial? | |
get '/glee' do | |
'happy!' | |
end | |
put '/gloom' do | |
'gloom :(' | |
end | |
end | |
before do | |
# why am I here? (see below) | |
@riz = params[:rep] | |
end | |
def qux | |
# why am I here? I only apply to one of several paths | |
# did I just mutate "global" state | |
xyzzy(env) | |
end | |
def fud | |
# aren't I part of the GET path's internal concerns? | |
params[:fef] * 200 | |
end | |
get '/' do | |
# (see above) because there's no room for you here | |
settings.bar.call(qux.merge(fud)) | |
end | |
patch '/suf' do | |
# here I am the last in line, maybe... | |
309 | |
end | |
... | |
end | |
# Sinatra/Rack adopts a fractal, compositional style, passing around a hash of state | |
# There is no room for state in the captured procs | |
# Why not move it down to an enclosed object? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But those things aren't solvable without significantly changing the API or even approach. I also guess you use Sinatra differently than I do.