HasRemote 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=d
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --exclude lib/generators --no-private --protected lib/**/*.rb - README.rdoc
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rails', '>= 3.0.0'
4
+
5
+ group :development do
6
+ gem 'sqlite3', '>= 1.3.4'
7
+ gem 'jeweler', '>= 1.6.4'
8
+ gem 'rspec', '>= 2.6.0'
9
+ gem 'shoulda-matchers', '>= 1.0.0.beta3'
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0)
6
+ actionpack (= 3.0.0)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0)
9
+ activemodel (= 3.0.0)
10
+ activesupport (= 3.0.0)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.12)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.0)
19
+ activesupport (= 3.0.0)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activerecord (3.0.0)
23
+ activemodel (= 3.0.0)
24
+ activesupport (= 3.0.0)
25
+ arel (~> 1.0.0)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.0)
28
+ activemodel (= 3.0.0)
29
+ activesupport (= 3.0.0)
30
+ activesupport (3.0.0)
31
+ arel (1.0.1)
32
+ activesupport (~> 3.0.0)
33
+ builder (2.1.2)
34
+ diff-lcs (1.1.2)
35
+ erubis (2.6.6)
36
+ abstract (>= 1.0.0)
37
+ git (1.2.5)
38
+ i18n (0.4.2)
39
+ jeweler (1.6.4)
40
+ bundler (~> 1.0)
41
+ git (>= 1.2.5)
42
+ rake
43
+ mail (2.2.19)
44
+ activesupport (>= 2.3.6)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.16)
49
+ polyglot (0.3.2)
50
+ rack (1.2.3)
51
+ rack-mount (0.6.14)
52
+ rack (>= 1.0.0)
53
+ rack-test (0.5.7)
54
+ rack (>= 1.0)
55
+ rails (3.0.0)
56
+ actionmailer (= 3.0.0)
57
+ actionpack (= 3.0.0)
58
+ activerecord (= 3.0.0)
59
+ activeresource (= 3.0.0)
60
+ activesupport (= 3.0.0)
61
+ bundler (~> 1.0.0)
62
+ railties (= 3.0.0)
63
+ railties (3.0.0)
64
+ actionpack (= 3.0.0)
65
+ activesupport (= 3.0.0)
66
+ rake (>= 0.8.4)
67
+ thor (~> 0.14.0)
68
+ rake (0.9.2)
69
+ rspec (2.6.0)
70
+ rspec-core (~> 2.6.0)
71
+ rspec-expectations (~> 2.6.0)
72
+ rspec-mocks (~> 2.6.0)
73
+ rspec-core (2.6.4)
74
+ rspec-expectations (2.6.0)
75
+ diff-lcs (~> 1.1.2)
76
+ rspec-mocks (2.6.0)
77
+ shoulda-matchers (1.0.0.beta3)
78
+ sqlite3 (1.3.4)
79
+ thor (0.14.6)
80
+ treetop (1.4.10)
81
+ polyglot
82
+ polyglot (>= 0.3.1)
83
+ tzinfo (0.3.29)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ jeweler (>= 1.6.4)
90
+ rails (>= 3.0.0)
91
+ rspec (>= 2.6.0)
92
+ shoulda-matchers (>= 1.0.0.beta3)
93
+ sqlite3 (>= 1.3.4)
data/HasRemote.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{HasRemote}
8
- s.version = "0.1.7"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Sjoerd Andringa"]
12
- s.date = %q{2010-12-28}
11
+ s.authors = [%q{Sjoerd Andringa}]
12
+ s.date = %q{2011-08-04}
13
13
  s.description = %q{Bind a remote ActiveResource object to your local ActiveRecord objects, delegate attributes and optionally cache remote attributes locally.}
14
14
  s.email = %q{sjoerd.andringa@innovationfactory.eu}
15
15
  s.extra_rdoc_files = [
@@ -17,57 +17,62 @@ Gem::Specification.new do |s|
17
17
  "TODO"
18
18
  ]
19
19
  s.files = [
20
+ ".rspec",
21
+ ".yardopts",
22
+ "Gemfile",
23
+ "Gemfile.lock",
20
24
  "HasRemote.gemspec",
21
25
  "MIT-LICENSE",
22
26
  "README.rdoc",
23
27
  "Rakefile",
24
28
  "TODO",
25
29
  "VERSION",
26
- "generators/has_remote_migration/has_remote_migration_generator.rb",
27
- "generators/has_remote_migration/templates/create_has_remote_synchronizations.erb",
28
- "init.rb",
30
+ "lib/generators/has_remote/migration_generator.rb",
31
+ "lib/generators/has_remote/templates/create_has_remote_synchronizations.rb",
29
32
  "lib/has_remote.rb",
33
+ "lib/has_remote/railtie.rb",
30
34
  "lib/has_remote/synchronizable.rb",
31
35
  "lib/has_remote/synchronization.rb",
32
- "lib/has_remote/tasks.rb",
33
- "rails/init.rb",
36
+ "lib/tasks/has_remote.rake",
34
37
  "shoulda_macros/has_remote_macros.rb",
35
38
  "spec/caching_spec.rb",
36
39
  "spec/database.yml",
37
40
  "spec/has_remote_spec.rb",
38
- "spec/has_remote_spec/book.rb",
39
- "spec/has_remote_spec/cheese.rb",
40
- "spec/has_remote_spec/product.rb",
41
- "spec/has_remote_spec/user.rb",
42
41
  "spec/schema.rb",
43
42
  "spec/spec_helper.rb",
44
- "spec/synchronization_spec.rb",
45
- "tasks/rails.rake"
43
+ "spec/support/book.rb",
44
+ "spec/support/cheese.rb",
45
+ "spec/support/product.rb",
46
+ "spec/support/user.rb",
47
+ "spec/synchronization_spec.rb"
46
48
  ]
47
49
  s.homepage = %q{http://github.com/innovationfactory/has_remote}
48
- s.require_paths = ["lib"]
49
- s.rubygems_version = %q{1.3.7}
50
+ s.require_paths = [%q{lib}]
51
+ s.rubygems_version = %q{1.8.6}
50
52
  s.summary = %q{Bind a remote ActiveResource object to your local ActiveRecord objects.}
51
- s.test_files = [
52
- "spec/caching_spec.rb",
53
- "spec/has_remote_spec.rb",
54
- "spec/has_remote_spec/book.rb",
55
- "spec/has_remote_spec/cheese.rb",
56
- "spec/has_remote_spec/product.rb",
57
- "spec/has_remote_spec/user.rb",
58
- "spec/schema.rb",
59
- "spec/spec_helper.rb",
60
- "spec/synchronization_spec.rb"
61
- ]
62
53
 
63
54
  if s.respond_to? :specification_version then
64
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
55
  s.specification_version = 3
66
56
 
67
57
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
+ s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
59
+ s.add_development_dependency(%q<sqlite3>, [">= 1.3.4"])
60
+ s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
61
+ s.add_development_dependency(%q<rspec>, [">= 2.6.0"])
62
+ s.add_development_dependency(%q<shoulda-matchers>, [">= 1.0.0.beta3"])
68
63
  else
64
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
65
+ s.add_dependency(%q<sqlite3>, [">= 1.3.4"])
66
+ s.add_dependency(%q<jeweler>, [">= 1.6.4"])
67
+ s.add_dependency(%q<rspec>, [">= 2.6.0"])
68
+ s.add_dependency(%q<shoulda-matchers>, [">= 1.0.0.beta3"])
69
69
  end
70
70
  else
71
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
72
+ s.add_dependency(%q<sqlite3>, [">= 1.3.4"])
73
+ s.add_dependency(%q<jeweler>, [">= 1.6.4"])
74
+ s.add_dependency(%q<rspec>, [">= 2.6.0"])
75
+ s.add_dependency(%q<shoulda-matchers>, [">= 1.0.0.beta3"])
71
76
  end
72
77
  end
73
78
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2010 Innovation Factory, Amsterdam
1
+ Copyright (c) 2009-2011 Innovation Factory, Amsterdam
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,28 +1,32 @@
1
1
  = HasRemote
2
2
 
3
- Binds your local ActiveRecord objects to a remote ActiveResource object,
3
+ Binds your local <tt>ActiveRecord</tt> objects to a remote <tt>ActiveResource</tt> object,
4
4
  which enables you to look for certain attributes remotely using a RESTful webservice.
5
5
 
6
6
  === Installation
7
7
 
8
- As a gem; Add the following to <tt>config/environment.rb</tt>:
8
+ ==== Rails 3
9
9
 
10
- config.gem 'HasRemote', :lib => 'has_remote'
10
+ Add the following to your <tt>Gemfile</tt>:
11
11
 
12
- Require the rake tasks from your application's <tt>Rakefile</tt> (only if installed as a gem):
12
+ gem 'HasRemote', '~> 0.2.0', :require => 'has_remote'
13
13
 
14
- require 'has_remote/tasks'
14
+ And only if you require synchronization, run:
15
+
16
+ rails generate has_remote:migration
17
+ rake db:migrate
18
+
19
+ ==== Rails 2.3
15
20
 
16
- As a plugin; Run:
21
+ Add the following to <tt>environment.rb</tt>:
17
22
 
18
- script/plugin install git://github.com/innovationfactory/has_remote.git
23
+ config.gem 'HasRemote', :version => '~> 0.1.7', :lib => 'has_remote'
19
24
 
20
25
  And only if you require synchronization, run:
21
26
 
22
27
  script/generate has_remote_migration
23
-
24
28
  rake db:migrate
25
-
29
+
26
30
  === Links
27
31
 
28
32
  [RDoc:] http://rdoc.info/projects/innovationfactory/has_remote
@@ -116,7 +120,7 @@ Synchronize all records of one specific model:
116
120
  The latter automatically requests all remote resources that have been changed (including new and deleted records) since the last successful synchronization for this particular model.
117
121
  You may need to override the <tt>updated_remotes</tt> class method in your model to match your host's REST API.
118
122
 
119
- See <tt>HasRemote::Synchronizable</tt> for more information.
123
+ See {HasRemote::Synchronizable} for more information.
120
124
 
121
125
  ==== Rake hr:sync
122
126
 
@@ -128,23 +132,22 @@ certain models by using the <tt>MODELS</tt> variable:
128
132
 
129
133
  rake hr:sync MODELS=Contact,Company
130
134
 
131
- To specify additional parameters to send with the request that fetches updated resources use the PARAMS variable:
135
+ To specify additional parameters to send with the request that fetches updated resources use the <tt>PARAMS</tt> variable:
132
136
 
133
137
  rake hr:sync PARAMS="since=01-01-2010&limit=25"
134
138
 
135
- (If you've overridden the <tt>updated_remotes</tt> class method on one of your synchronizable models, then note that these parameters are
136
- passed in as a hash to <tt>updated_remotes</tt> internally.)
139
+ (If you've overridden the {HasRemote::Synchronizable#updated_remotes #updated_remotes} class method on one of your synchronizable models, then note that these parameters are
140
+ passed in as a hash to {HasRemote::Synchronizable#updated_remotes #updated_remotes} internally.)
137
141
 
138
142
  === Testing
139
143
 
140
- To run the specs of the plugin, from the HasRemote directory run:
141
- rake spec
142
-
143
- (This requires you to have both RSpec and Shoulda installed.)
144
+ Install Bundler and run <tt>bundle install</tt> in order to obtain RSpec and other dependencies.
145
+ To run the specs, from the root folder run:
146
+ rspec spec
144
147
 
145
148
  === More information & patches
146
149
 
147
150
  Questions, requests and patches can be directed to sjoerd.andringa[AT]innovationfactory[DOT]eu.
148
151
 
149
152
 
150
- Copyright (c) 2009-2010 Innovation Factory.
153
+ Copyright (c) 2009-2011 Innovation Factory.
data/Rakefile CHANGED
@@ -1,35 +1,18 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'rake/rdoctask'
4
- require 'spec/rake/spectask'
5
-
6
- desc 'Generate documentation for the has_remote plugin.'
7
- Rake::RDocTask.new(:rdoc) do |rdoc|
8
- rdoc.rdoc_dir = 'doc'
9
- rdoc.title = 'HasRemote'
10
- rdoc.options << '--line-numbers' << '--inline-source'
11
- rdoc.rdoc_files.include('README.rdoc')
12
- rdoc.rdoc_files.include('lib/**/*.rb')
13
- rdoc.rdoc_files.exclude('lib/generators')
14
- end
15
-
16
- desc "Run all RSpec examples"
17
- Spec::Rake::SpecTask.new('spec') do |t|
18
- t.spec_files = FileList['spec/**/*_spec.rb']
19
- t.spec_opts = %w(-cfs)
20
- end
21
3
 
22
4
  begin
23
5
  require 'jeweler'
24
- Jeweler::Tasks.new do |gemspec|
25
- gemspec.name = "HasRemote"
26
- gemspec.summary = "Bind a remote ActiveResource object to your local ActiveRecord objects."
27
- gemspec.description = "Bind a remote ActiveResource object to your local ActiveRecord objects, delegate attributes and optionally cache remote attributes locally."
28
- gemspec.email = "sjoerd.andringa@innovationfactory.eu"
29
- gemspec.homepage = "http://github.com/innovationfactory/has_remote"
30
- gemspec.authors = ["Sjoerd Andringa"]
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "HasRemote"
8
+ gem.version = File.read('VERSION').chomp
9
+ gem.summary = "Bind a remote ActiveResource object to your local ActiveRecord objects."
10
+ gem.description = "Bind a remote ActiveResource object to your local ActiveRecord objects, delegate attributes and optionally cache remote attributes locally."
11
+ gem.email = "sjoerd.andringa@innovationfactory.eu"
12
+ gem.homepage = "http://github.com/innovationfactory/has_remote"
13
+ gem.authors = ["Sjoerd Andringa"]
31
14
  end
32
- Jeweler::GemcutterTasks.new
15
+ Jeweler::RubygemsDotOrgTasks.new
33
16
  rescue LoadError
34
17
  puts "Jeweler not available. Install it with: gem install jeweler"
35
18
  end
data/TODO CHANGED
@@ -15,7 +15,7 @@
15
15
  <user>
16
16
  <id type="integer">1</id>
17
17
  <remote site="...">
18
- <id type="integer">1</id>
19
- <name>George Remote</name>
20
- </remote>
18
+ <id type="integer">1</id>
19
+ <name>George Remote</name>
20
+ </remote>
21
21
  </user>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.2.0
@@ -0,0 +1,20 @@
1
+ require 'rails/generators/active_record/migration'
2
+
3
+ module HasRemote
4
+ module Generators
5
+ class MigrationGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ extend ActiveRecord::Generators::Migration
8
+
9
+ source_root File.join(File.dirname(__FILE__), 'templates')
10
+
11
+ desc <<-TXT.squish
12
+ Creates a migration that will set up the has_remote_synchronizations table. You don't need this
13
+ if you don't plan on synchronizing cached remote attributes.
14
+ TXT
15
+ def create_migration
16
+ migration_template "create_has_remote_synchronizations.rb", "db/migrate/create_has_remote_synchronizations.rb"
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/has_remote.rb CHANGED
@@ -1,8 +1,12 @@
1
- # The main module for the has_remote plugin. Please see README for more information.
1
+ require 'has_remote/synchronizable'
2
+ require 'has_remote/synchronization'
3
+ require 'has_remote/railtie'
4
+
5
+ # The main module for the has_remote plugin. Please see {file:README.rdoc README} for more information.
2
6
  #
3
7
  module HasRemote
4
8
 
5
- def self.included(base) #:nodoc:
9
+ def self.included(base)
6
10
  base.extend ClassMethods
7
11
  end
8
12
 
@@ -10,13 +14,15 @@ module HasRemote
10
14
  #
11
15
  def self.models
12
16
  # Make sure all models are loaded:
13
- Dir[File.join(RAILS_ROOT, 'app', 'models', '*.rb')].each { |f| require_dependency f }
17
+ if Rails.root
18
+ Dir[Rails.root.join('app', 'models', '*.rb')].each { |f| require_dependency f }
19
+ end
14
20
 
15
21
  @models ||= []
16
22
  end
17
23
 
18
24
  # Updates cached attributes, destroys deleted records and adds new records of all models that have a remote.
19
- # Also see HasRemote::Synchronizable.
25
+ # Also see {HasRemote::Synchronizable}.
20
26
  #
21
27
  def self.synchronize!
22
28
  models.each(&:synchronize!)
@@ -24,20 +30,10 @@ module HasRemote
24
30
 
25
31
  module ClassMethods
26
32
 
27
- # Gives your local ActiveRecord model a remote proxy (ActiveResource::Base),
28
- # which enables you to look for certain attributes remotely.
29
- #
30
- # ==== Options
33
+ # Binds your <tt>ActiveRecord</tt> objects to a remote <tt>ActiveResource</tt> resource,
34
+ # and enables you to look for certain attributes remotely.
31
35
  #
32
- # [:foreign_key] The name of the column used to store the id of the remote resource. Defaults to :remote_id.
33
- # [:remote_primary_key] The name of the remote resource's primary key. Defaults to :id.
34
- # [:site, :user, :password, ...] Basically all ActiveResource configuration settings are available,
35
- # see http://api.rubyonrails.org/classes/ActiveResource/Base.html
36
- # [:through] Optional custom ActiveResource class name to use for the proxy. If not set, a default class called
37
- # "<ModelName>::Remote" will be created dynamically. *Note* that any ActiveResource
38
- # configuration options will still be applied to this class.
39
- #
40
- # ==== Usage
36
+ # ==== Usage:
41
37
  #
42
38
  # class User < ActiveRecord::Base
43
39
  # has_remote :site => 'http://people.local'
@@ -51,7 +47,7 @@ module HasRemote
51
47
  # User.find(1).remote.username
52
48
  # # => "User name from remote server"
53
49
  #
54
- # has_remote also takes a block which is passed in a HasRemote::Config object which can be used to specify
50
+ # has_remote also takes a block which is passed in a {Config} object which can be used to specify
55
51
  # remote attributes:
56
52
  #
57
53
  # class User < ActiveRecord::Base
@@ -65,9 +61,17 @@ module HasRemote
65
61
  # User.find(1).username
66
62
  # # => "User name from remote server"
67
63
  #
64
+ # @option options [Symbol, String] :foreign_key (:remote_id) The name of the column used to store the id of the remote resource..
65
+ # @option options [Symbol, String] :remote_primary_key (:id) The name of the remote resource's primary key.
66
+ # @option options [String] :through Optional custom <tt>ActiveResource</tt> class name to use for the proxy. If not set, a default class called
67
+ # <tt>Remote</tt> will be created dynamically, namespaced inside the current model. *Note* that any <tt>ActiveResource</tt>
68
+ # configuration options will still be applied to this class.
69
+ # @option options Other All other options you pass in will be used to configure the <tt>ActiveResource</tt> model, you can use any setting for {http://api.rubyonrails.org/classes/ActiveResource/Base.html ActiveResource::Base}, such as <tt>:site</tt>, <tt>:user</tt> and <tt>:password</tt>.
70
+ # @yieldparam [Config] remote Configure attributes to be delegated or a custom finder.
71
+ #
68
72
  def has_remote(options, &block)
69
73
  unless options[:through] || self.const_defined?("Remote")
70
- self.const_set("Remote", ActiveResource::Base.clone)
74
+ self.const_set("Remote", Class.new(ActiveResource::Base))
71
75
  end
72
76
 
73
77
  @remote_class = options[:through] ? options.delete(:through).constantize : self::Remote
@@ -117,12 +121,10 @@ module HasRemote
117
121
 
118
122
  module InstanceMethods
119
123
 
120
- # Returns the remote proxy for this record as an <tt>ActiveResource::Base</tt> object. Returns nil
121
- # if foreign key is nil.
124
+ # Returns the remote proxy for this record as an <tt>ActiveResource::Base</tt> object. Returns <tt>nil</tt>
125
+ # if foreign key is <tt>nil</tt>.
122
126
  #
123
- # *Arguments*
124
- #
125
- # - <tt>force_reload</tt>: Forces a reload from the remote server if set to true. Defaults to false.
127
+ # @param [Boolean] force_reload Forces a reload from the remote server if set to <tt>true</tt>.
126
128
  #
127
129
  def remote(force_reload = false)
128
130
  if force_reload || @remote.nil?
@@ -134,6 +136,8 @@ module HasRemote
134
136
 
135
137
  # Checks whether a remote proxy exists.
136
138
  #
139
+ # @return [Boolean]
140
+ #
137
141
  def has_remote?
138
142
  # NOTE ARes#exists? is broken:
139
143
  # https://rails.lighthouseapp.com/projects/8994/tickets/1223-activeresource-head-request-sends-headers-with-a-nil-key
@@ -143,6 +147,8 @@ module HasRemote
143
147
 
144
148
  # Synchronizes all locally cached remote attributes to this object and saves the object.
145
149
  #
150
+ # @raise [ActiveRecord::RecordInvalid]
151
+ #
146
152
  def update_cached_attributes!
147
153
  update_cached_attributes
148
154
  save!
@@ -151,7 +157,7 @@ module HasRemote
151
157
  # Synchronizes all locally cached remote attributes to this object, but does not save the object.
152
158
  #
153
159
  # Note that when the remote does no longer exist, all remote attributes will be
154
- # set to nil.
160
+ # set to <tt>nil</tt>.
155
161
  #
156
162
  def update_cached_attributes
157
163
  unless self.skip_update_cache || self.class.cached_attributes.empty?
@@ -165,20 +171,19 @@ module HasRemote
165
171
 
166
172
  end
167
173
 
174
+ # The block argument for {HasRemote::ClassMethods#has_remote} is an instance of this class.
175
+ # It can be used to configure HasRemote's behaviour for a model.
176
+ #
168
177
  class Config
178
+
179
+ # @private
169
180
  def initialize(base) #:nodoc:
170
181
  @base = base
171
182
  end
172
183
 
173
184
  # Defines a remote attribute. Adds a getter method on instances, which delegates to the remote object.
174
185
  #
175
- # *Options*
176
- #
177
- # [:local_cache] If set to true the attribute will also be saved locally. See README for more information
178
- # about caching and synchronization.
179
- # [:as] Optionally map remote attribute to this name.
180
- #
181
- # *Example*
186
+ # ==== Example:
182
187
  #
183
188
  # class User < ActiveRecord::Base
184
189
  # has_remote :site => '...' do |remote|
@@ -187,6 +192,11 @@ module HasRemote
187
192
  # end
188
193
  # end
189
194
  #
195
+ # @param [String, Symbol] attr_name The name of the attribute you want to delegate to the remote.
196
+ # @option options [Boolean] :local_cache (false) If set to <tt>true</tt> the attribute will also be saved locally. See {file:README.rdoc README} for more information
197
+ # about caching and synchronization.
198
+ # @option options [Symbol, String] :as Optionally map the remote attribute to this name.
199
+ #
190
200
  def attribute(attr_name, options = {})
191
201
  method_name = options[:as] || attr_name
192
202
 
@@ -212,12 +222,12 @@ module HasRemote
212
222
  end
213
223
 
214
224
  # Lets you specify custom finder logic to find the record's remote object.
215
- # It takes a block which is passed in the id of the remote object.
225
+ # It takes a block which is passed in the ID of the remote object.
216
226
  #
217
- # (By default <tt>Model.remote_class.find(id)</tt> would be called.)
218
- #
219
- # *Example*
227
+ # By default the following finder is used:
228
+ # MyModel.remote_class.find(id)
220
229
  #
230
+ # ==== Example:
221
231
  # class User < ActiveRecord::Base
222
232
  # has_remote :site => "..." do |remote|
223
233
  # remote.finder do |id|
@@ -231,5 +241,4 @@ module HasRemote
231
241
  end
232
242
 
233
243
  end
234
-
235
244
  end