title: How to make this Sinatra code DRYer?
body: <p>These are my Sinatra routes. They pass the storename as an ActiveRecord class and the params with which my helpermethods do what they have to.</p>
  
  <pre><code>def self.get_or_post(url,&amp;block)
    get(url,&amp;block)
    post(url,&amp;block)
  end
  
  get_or_post "/read" do
    jsonp(read(params[:store].constantize, params))
  end
  
  get_or_post "/create" do
    jsonp(create(params[:store].constantize, params))
  end
  
  get_or_post "/update" do
    jsonp(update(params[:store].constantize, params))
  end
  
  get_or_post "/destroy" do
    jsonp(destroy(params[:store].constantize, params))
  end
  </code></pre>
  
  <p>It seems to me this can be made DRYer doing something like:</p>
  
  <pre><code>case route
  when read, create, update, destroy
    jsonp(method(route).call(params[:store].constantize, params))
  else
    # neglect or give error
  end
  </code></pre>
  
  <p>How can I get this route variable, and is my use of <code>method(route).call</code> correct?</p>