Skip to content

Instantly share code, notes, and snippets.

@jhchabran
Created September 2, 2009 12:40
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 jhchabran/179694 to your computer and use it in GitHub Desktop.
Save jhchabran/179694 to your computer and use it in GitHub Desktop.
class RestfulActions
include Singleton
Action = Struct.new(:name, :method, :args)
@@actions = []
[
[:index, :get],
[:new, :get],
[:show, :get, {:id => 1}],
[:edit, :get, {:id => 1}],
[:create, :post, {:foo => 'lol'}],
[:update, :put, {:id => 1}],
[:destroy, :delete, {:id => 1}]
].each do |opts|
@@actions << Action.new(*opts)
end
def each(&block)
@@actions.each do |action|
yield action
end
end
def self.each(&block)
instance.each(&block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment