Skip to content

Instantly share code, notes, and snippets.

@jeffomatic
Created March 7, 2012 23:47
Show Gist options
  • Save jeffomatic/1997346 to your computer and use it in GitHub Desktop.
Save jeffomatic/1997346 to your computer and use it in GitHub Desktop.
factual-ruby-driver monkey patch for namespace lookup
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