This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The Riak object "b1/a" is linked to objects in "b2". | |
| # The objects in "b2" contain a JSON hash with a "links" key. This list contains an array of ids. | |
| # The objects "b3/idX" are the final objects, we can process them in maps and a reduce. | |
| results = Riak::MapReduce.new(client). | |
| add('b1', 'a'). | |
| # link-walk to objects in 'b2' | |
| link({:bucket => 'b2', :tag => '_', :keep => false}). | |
| # return a array of tuples [bucket, id], that Riak will recognize and follow | |
| map("function(v, keydata, arg) { return v.not_found ? [] : JSON.parse(v.values[0].data).links.map(function(x) { return [arg, x]; }); }", :keep => false, :arg => 'b3'). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Monkey patch Facebooker to set an access token instead of a session key, | |
| # and use the access token on EVERY requests. | |
| Facebooker::Session.class_eval do | |
| def post_without_logging_with_access_token(method, params = {}, use_session_key = true, &proc) | |
| params[:access_token] ||= (params.delete(:session_key) || @session_key) | |
| post_without_logging_without_access_token(method, params, false, &proc) | |
| end | |
| alias_method_chain :post_without_logging, :access_token | |
| end |
NewerOlder