Skip to content

Instantly share code, notes, and snippets.

@jamiehodge
Last active December 16, 2015 06:19
Show Gist options
  • Save jamiehodge/5390925 to your computer and use it in GitHub Desktop.
Save jamiehodge/5390925 to your computer and use it in GitHub Desktop.
What am I?
# 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?
@rkh
Copy link

rkh commented Apr 15, 2013

But those things aren't solvable without significantly changing the API or even approach. I also guess you use Sinatra differently than I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment