RailsでGemsを拡張する勉強がてらにとりあえずで
- Rails 3.0.3
- FacebookOAuth 0.2.2
使い方 client.me.action namespace, type, { :[ACTION] => url }
config/initializers/facebook_oauth.rb
FacebookOAuth::FacebookObject.class_eval do
def method_missing(method, *args)
if method.to_s == 'action'
namespace = args.shift
type = args.shift
params = args.first || {}
raise ArgumentError if namespace.nil?
raise ArgumentError if type.nil?
@client.send(:_post, "/#{@oid}/#{namespace}:#{type}", params)
return
end
first = args.shift
params = args.first || {}
if first and first == :create
@client.send(:_post, "/#{@oid}/#{method.to_s}", params)
else
@client.send(:_get, "/#{@oid}/#{method.to_s}")
end
end
end