Permalink
Browse files

Updates some docuemtation for adding adapters.

  • Loading branch information...
1 parent db700c4 commit 539127dc6a88bba4c78dc3c79c4fab0f6209a71a @james2m committed May 1, 2011
Showing with 31 additions and 1 deletion.
  1. +8 −1 README.rdoc
  2. +23 −0 lib/authlogic_facebook_shim/session/adapter.rb
View
@@ -1,6 +1,8 @@
= authlogic_facebook_shim
-This is a plugin for integrating facebook sessions into authlogic.
+This is a plugin for integrating facebook sessions into authlogic. It relies on using the Javascript SDK to
+login to facebook. Currently the shim support koala (https://github.com/arsduo/koala) for access the graph API
+but if you have a preferred library it is easy to add an adapter.
This requires a config/facebook.yml file that looks like this:
@@ -48,6 +50,11 @@ To get hold of the facebook particulars you will need to add something like this
current_user_session.try(:facebook_session?)
end
+== Adapters
+
+Currently the only adapter in the shim is for koala (https://github.com/arsduo/koala) but if you have a preferred
+wrapper for accessing the graph API please fork the project and add your own adapter (with tests) then send me a pull
+request.
== Note on Patches/Pull Requests
@@ -1,6 +1,29 @@
module AuthlogicFacebookShim
module Session
module Adapter
+
+ # The adapter requires 3 methods;
+ #
+ # facebook_session should return an OpenStruct or similar object that returns the users
+ # uid and access_token when those methods are called.
+ #
+ # facebook_session? should just return true if there is a facebook session i.e. the
+ # facebook fbs_FACEBOOK_APP_ID cookie has been set.
+ #
+ # facebook_user should return an OpenStruct or similar object that returns the users
+ # properties by responding to methods of the same name. The one execption to this rule
+ # is the facebook property id is replaced with a property uid to aviod clashing with
+ # the Object#id method in Ruby.
+ #
+ # The Facebook user properties are documented here
+ # http://developers.facebook.com/docs/reference/api/user/
+
+
+ # The shim chooses which adapter to use by checking for a constant derived from the name
+ # of the adapter for example to load the koala_adapter the shim first checks for the
+ # existence of the Koala constant so you need to ensure you load Koala first. Likewise
+ # an adapter for Mogli needs to be called mogli_adapter.rb and Facebooker2 would be
+ # facebooker2_adapter.rb
Dir[File.expand_path('../adapters/*.rb', File.dirname(__FILE__))].each do |adapter|
class_name = File.basename(adapter).rpartition(/_adapter\.rb$/).shift.camelize
if defined?(class_name)

0 comments on commit 539127d

Please sign in to comment.