Skip to content

Instantly share code, notes, and snippets.

@mwunsch
Created May 12, 2009 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwunsch/110536 to your computer and use it in GitHub Desktop.
Save mwunsch/110536 to your computer and use it in GitHub Desktop.
Weary DSL brainstorming
# DSL method ideas (for Weary)
class Twitter < Weary::Base
on_domain 'http://twitter.com/'
as_format :json
declare_resource 'statuses/user_timeline',
:via => :get,
:with => [:id],
:forms_url => "#{domain}#{resource}.#{format}?#{query}"
declare_resource 'statuses' do
get :show,
:with => [:id],
:requires => [:id],
:forms_url => "#{domain}#{resource}.#{format}?#{query}"
post :update,
:with => [:status, :in_reply_to_status_id],
:requires => [:status],
:authenticate => true
end
end
# Need to setup some way to declare a default 'forms_url'.
# Maybe this will be a method that exists outside of the declare_resource method.
# constructs_url or something like that
# If within the declare_resource block GET and POST share the same method (see Github API)
# we should set up getters and setters e.g.
# get :show
# post :show
# will create methods show and show=
# twitter.statuses.show({query}) will perform the GET
# twitter.statuses.show = {some hash that represents the request.body} performs the POST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment