Created
August 27, 2009 14:38
-
-
Save s-andringa/176335 to your computer and use it in GitHub Desktop.
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 User < ActiveRecord::Base | |
def email | |
# Make REST call, parse response, extract email address and return it. | |
# Probably not the most concise and expressive code. | |
end | |
end | |
# Is more or less equal to: | |
class RemoteUser < ActiveResource::Base | |
self.site = "..." | |
end | |
class User < ActiveRecord::Base | |
def email | |
RemoteUser.find(remote_user_id).email | |
end | |
end | |
# Is equal to: | |
class User < ActiveRecord::Base | |
has_remote :site => "..." | |
def email | |
User::Remote.find(remote_user_id).email | |
end | |
end | |
# Is equal to: | |
class User < ActiveRecord::Base | |
has_remote :site => "..." | |
def email | |
remote.email | |
end | |
end | |
# Is equal to: | |
class User < ActiveRecord::Base | |
has_remote :site => "..." do |r| | |
r.attribute :email | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment