Created
March 7, 2012 23:47
-
-
Save jeffomatic/1997346 to your computer and use it in GitHub Desktop.
factual-ruby-driver monkey patch for namespace lookup
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
require 'factual/query/crosswalk' | |
unless Factual::Query::Crosswalk.instance_methods.include?(:namespace) | |
class Factual | |
module Query | |
class CrosswalkNamespace < Base | |
def initialize(api, params = {}) | |
@path = "places/crosswalk" | |
@action = :crosswalk | |
super(api, params) | |
end | |
[ | |
:namespace, :namespace_id, | |
:factual_id, :only, :limit, :include_count | |
].each do |param| | |
define_method(param) do |*args| | |
self.class.new(@api, @params.merge(param => form_value(args))) | |
end | |
end | |
end | |
end | |
end | |
class Factual | |
def crosswalk_namespace(namespace, namespace_id) | |
Query::CrosswalkNamespace.new( | |
@api, | |
:namespace => namespace, | |
:namespace_id => namespace_id | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment