Created
November 29, 2011 10:12
-
-
Save troex/1404284 to your computer and use it in GitHub Desktop.
Hack ActiveResource::Base to support per instance site option
This file contains 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
class Runner | |
@@nodes = {} | |
def self.node(site) | |
@@nodes[site] || = self.new_ar(site).new if !@@nodes.has_key?(site) | |
end | |
def self.new_ar(site) | |
Class.new(ActiveResource::Base) do | |
self.site = site | |
self.element_name = 'runner' | |
# your methods here | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: