Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove Active Resource source files from the repository

Dear Active Resource,

It's not that I hate you or anything, but you didn't get much attention lately. There're so many alternatives out there, and I think people have made their choice to use them than you. I think it's time for you to have a big rest, peacefully in this Git repository.

I will miss you,

@sikachu.
  • Loading branch information...
commit f1637bf2bb00490203503fbd943b73406e043d1d 1 parent a85714a
Prem Sichanugrist sikachu authored

Showing 68 changed files with 13 additions and 7,147 deletions. Show diff stats Hide diff stats

  1. +1 7 Rakefile
  2. +2 2 actionpack/lib/action_controller/record_identifier.rb
  3. +1 1  actionpack/lib/action_view/helpers/url_helper.rb
  4. +1 1  activemodel/activemodel.gemspec
  5. +0 390 activeresource/CHANGELOG.md
  6. +0 20 activeresource/MIT-LICENSE
  7. +0 189 activeresource/README.rdoc
  8. +0 66 activeresource/Rakefile
  9. +0 24 activeresource/activeresource.gemspec
  10. +0 70 activeresource/examples/performance.rb
  11. +0 45 activeresource/lib/active_resource.rb
  12. +0 1,515 activeresource/lib/active_resource/base.rb
  13. +0 284 activeresource/lib/active_resource/connection.rb
  14. +0 127 activeresource/lib/active_resource/custom_methods.rb
  15. +0 82 activeresource/lib/active_resource/exceptions.rb
  16. +0 22 activeresource/lib/active_resource/formats.rb
  17. +0 25 activeresource/lib/active_resource/formats/json_format.rb
  18. +0 25 activeresource/lib/active_resource/formats/xml_format.rb
  19. +0 332 activeresource/lib/active_resource/http_mock.rb
  20. +0 15 activeresource/lib/active_resource/log_subscriber.rb
  21. +0 29 activeresource/lib/active_resource/observing.rb
  22. +0 14 activeresource/lib/active_resource/railtie.rb
  23. +0 59 activeresource/lib/active_resource/schema.rb
  24. +0 172 activeresource/lib/active_resource/validations.rb
  25. +0 10 activeresource/lib/active_resource/version.rb
  26. +0 143 activeresource/test/abstract_unit.rb
  27. +0 251 activeresource/test/cases/authorization_test.rb
  28. +0 101 activeresource/test/cases/base/custom_methods_test.rb
  29. +0 52 activeresource/test/cases/base/equality_test.rb
  30. +0 199 activeresource/test/cases/base/load_test.rb
  31. +0 411 activeresource/test/cases/base/schema_test.rb
  32. +0 137 activeresource/test/cases/base_errors_test.rb
  33. +0 1,177 activeresource/test/cases/base_test.rb
  34. +0 275 activeresource/test/cases/connection_test.rb
  35. +0 139 activeresource/test/cases/finder_test.rb
  36. +0 118 activeresource/test/cases/format_test.rb
  37. +0 202 activeresource/test/cases/http_mock_test.rb
  38. +0 32 activeresource/test/cases/log_subscriber_test.rb
  39. +0 55 activeresource/test/cases/observing_test.rb
  40. +0 67 activeresource/test/cases/validations_test.rb
  41. +0 19 activeresource/test/fixtures/address.rb
  42. +0 14 activeresource/test/fixtures/beast.rb
  43. +0 3  activeresource/test/fixtures/customer.rb
  44. +0 3  activeresource/test/fixtures/person.rb
  45. +0 18 activeresource/test/fixtures/project.rb
  46. +0 4 activeresource/test/fixtures/proxy.rb
  47. +0 9 activeresource/test/fixtures/sound.rb
  48. +0 4 activeresource/test/fixtures/street_address.rb
  49. +0 5 activeresource/test/fixtures/subscription_plan.rb
  50. +0 26 activeresource/test/setter_trap.rb
  51. +0 1  ci/travis.rb
  52. +1 1  install.rb
  53. +0 1  rails.gemspec
  54. +2 0  railties/CHANGELOG.md
  55. +0 120 railties/guides/source/active_resource_basics.textile
  56. +0 1  railties/guides/source/command_line.textile
  57. +0 8 railties/guides/source/configuring.textile
  58. +0 7 railties/guides/source/getting_started.textile
  59. +0 2  railties/guides/source/initialization.textile
  60. +0 1  railties/lib/rails/all.rb
  61. +0 1  railties/lib/rails/generators/rails/app/templates/config/application.rb
  62. +0 1  railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb
  63. +2 2 railties/lib/rails/info.rb
  64. +1 1  railties/lib/rails/railtie.rb
  65. +0 6 railties/lib/rails/tasks/documentation.rake
  66. +1 2  railties/test/isolation/abstract_unit.rb
  67. +1 1  tasks/release.rb
  68. +0 1  tools/profile
8 Rakefile
@@ -13,7 +13,7 @@ task :build => "all:build"
13 13 desc "Release all gems to gemcutter and create a tag"
14 14 task :release => "all:release"
15 15
16   -PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
  16 +PROJECTS = %w(activesupport activemodel actionpack actionmailer activerecord railties)
17 17
18 18 desc 'Run all tests by default'
19 19 task :default => %w(test test:isolated)
@@ -109,11 +109,6 @@ RDoc::Task.new do |rdoc|
109 109 rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
110 110 rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')
111 111
112   - rdoc.rdoc_files.include('activeresource/README.rdoc')
113   - rdoc.rdoc_files.include('activeresource/CHANGELOG.md')
114   - rdoc.rdoc_files.include('activeresource/lib/active_resource.rb')
115   - rdoc.rdoc_files.include('activeresource/lib/active_resource/*')
116   -
117 112 rdoc.rdoc_files.include('actionpack/README.rdoc')
118 113 rdoc.rdoc_files.include('actionpack/CHANGELOG.md')
119 114 rdoc.rdoc_files.include('actionpack/lib/abstract_controller/**/*.rb')
@@ -157,7 +152,6 @@ task :update_versions do
157 152 "activemodel" => "ActiveModel",
158 153 "actionpack" => "ActionPack",
159 154 "actionmailer" => "ActionMailer",
160   - "activeresource" => "ActiveResource",
161 155 "activerecord" => "ActiveRecord",
162 156 "railties" => "Rails"
163 157 }
4 actionpack/lib/action_controller/record_identifier.rb
@@ -2,8 +2,8 @@
2 2
3 3 module ActionController
4 4 # The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
5   - # Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate
6   - # the view actions to a higher logical level. Example:
  5 + # pretty much any other model type that has an id. These patterns are then used to try elevate the view actions to
  6 + # a higher logical level. Example:
7 7 #
8 8 # # routes
9 9 # resources :posts
2  actionpack/lib/action_view/helpers/url_helper.rb
@@ -60,7 +60,7 @@ def optimize_routes_generation? #:nodoc:
60 60 #
61 61 # ==== Relying on named routes
62 62 #
63   - # Passing a record (like an Active Record or Active Resource) instead of a Hash as the options parameter will
  63 + # Passing a record (like an Active Record) instead of a Hash as the options parameter will
64 64 # trigger the named route for that record. The lookup will happen on the name of the class. So passing a
65 65 # Workshop object will attempt to use the +workshop_path+ route. If you have a nested route, such as
66 66 # +admin_workshop_path+ you'll have to call that explicitly (it's impossible for +url_for+ to guess that route).
2  activemodel/activemodel.gemspec
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5 5 s.name = 'activemodel'
6 6 s.version = version
7 7 s.summary = 'A toolkit for building modeling frameworks (part of Rails).'
8   - s.description = 'A toolkit for building modeling frameworks like Active Record and Active Resource. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.'
  8 + s.description = 'A toolkit for building modeling frameworks like Active Record. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.'
9 9
10 10 s.required_ruby_version = '>= 1.9.3'
11 11
390 activeresource/CHANGELOG.md
Source Rendered
... ... @@ -1,390 +0,0 @@
1   -## Rails 4.0.0 (unreleased) ##
2   -
3   -* Adds support for PATCH requests. *dlee*
4   -
5   -
6   -## Rails 3.2.2 (March 1, 2012) ##
7   -
8   -* No changes.
9   -
10   -
11   -## Rails 3.2.1 (January 26, 2012) ##
12   -
13   -* Documentation fixes.
14   -
15   -
16   -## Rails 3.2.0 (January 20, 2012) ##
17   -
18   -* Redirect responses: 303 See Other and 307 Temporary Redirect now behave like
19   - 301 Moved Permanently and 302 Found. GH #3302.
20   -
21   - *Jim Herz*
22   -
23   -
24   -## Rails 3.1.4 (March 1, 2012) ##
25   -
26   -* No changes
27   -
28   -
29   -## Rails 3.1.3 (November 20, 2011) ##
30   -
31   -* No changes
32   -
33   -
34   -## Rails 3.1.2 (November 18, 2011) ##
35   -
36   -* No changes
37   -
38   -
39   -## Rails 3.1.1 (October 7, 2011) ##
40   -
41   -* No changes.
42   -
43   -
44   -## Rails 3.1.0 (August 30, 2011) ##
45   -
46   -* The default format has been changed to JSON for all requests. If you want to continue to use XML you will need to set `self.format = :xml` in the class. eg.
47   -
48   - class User < ActiveResource::Base self.format = :xml
49   - end
50   -
51   -
52   -## Rails 3.0.12 (March 1, 2012) ##
53   -
54   -* No changes.
55   -
56   -
57   -## Rails 3.0.11 (November 18, 2011) ##
58   -
59   -* No changes.
60   -
61   -
62   -## Rails 3.0.10 (August 16, 2011) ##
63   -
64   -* No changes.
65   -
66   -
67   -## Rails 3.0.9 (June 16, 2011) ##
68   -
69   -* No changes.
70   -
71   -
72   -## Rails 3.0.8 (June 7, 2011) ##
73   -
74   -* No Changes
75   -
76   -
77   -## Rails 3.0.7 (April 18, 2011) ##
78   -
79   -* No changes.
80   -
81   -
82   -## Rails 3.0.6 (April 5, 2011) ##
83   -
84   -* No changes.
85   -
86   -
87   -## Rails 3.0.5 (February 26, 2011) ##
88   -
89   -* No changes.
90   -
91   -
92   -## Rails 3.0.4 (February 8, 2011) ##
93   -
94   -* No changes.
95   -
96   -
97   -## Rails 3.0.3 (November 16, 2010) ##
98   -
99   -* No changes.
100   -
101   -
102   -## Rails 3.0.2 (November 15, 2010) ##
103   -
104   -* No changes
105   -
106   -
107   -## Rails 3.0.1 (October 15, 2010) ##
108   -
109   -* No Changes, just a version bump.
110   -
111   -
112   -## Rails 3.0.0 (August 29, 2010) ##
113   -
114   -* JSON: set Base.include_root_in_json = true to include a root value in the JSON: {"post": {"title": ...}}. Mirrors the Active Record option. *Santiago Pastorino*
115   -
116   -* Add support for errors in JSON format. #1956 *Fabien Jakimowicz*
117   -
118   -* Recognizes 410 as Resource Gone. #2316 *Jordan Brough, Jatinder Singh*
119   -
120   -* More thorough SSL support. #2370 *Roy Nicholson*
121   -
122   -* HTTP proxy support. #2133 *Marshall Huss, Sébastien Dabet*
123   -
124   -
125   -## 2.3.2 Final (March 15, 2009) ##
126   -
127   -* Nothing new, just included in 2.3.2
128   -
129   -
130   -## 2.2.1 RC2 (November 14th, 2008) ##
131   -
132   -* Fixed that ActiveResource#post would post an empty string when it shouldn't be posting anything #525 *Paolo Angelini*
133   -
134   -
135   -## 2.2.0 RC1 (October 24th, 2008) ##
136   -
137   -* Add ActiveResource::Base#to_xml and ActiveResource::Base#to_json. #1011 *Rasik Pandey, Cody Fauser*
138   -
139   -* Add ActiveResource::Base.find(:last). [#754 state:resolved] (Adrian Mugnolo)
140   -
141   -* Fixed problems with the logger used if the logging string included %'s [#840 state:resolved] (Jamis Buck)
142   -
143   -* Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)
144   -
145   -
146   -## 2.1.0 (May 31st, 2008) ##
147   -
148   -* Fixed response logging to use length instead of the entire thing (seangeo) *#27*
149   -
150   -* Fixed that to_param should be used and honored instead of hardcoding the id #11406 *gspiers*
151   -
152   -* Improve documentation. *Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert*
153   -
154   -* Use HEAD instead of GET in exists? *bscofield*
155   -
156   -* Fix small documentation typo. Closes #10670 *Luca Guidi*
157   -
158   -* find_or_create_resource_for handles module nesting. #10646 *xavier*
159   -
160   -* Allow setting ActiveResource::Base#format before #site. *Rick Olson*
161   -
162   -* Support agnostic formats when calling custom methods. Closes #10635 *joerichsen*
163   -
164   -* Document custom methods. #10589 *Cheah Chu Yeow*
165   -
166   -* Ruby 1.9 compatibility. *Jeremy Kemper*
167   -
168   -
169   -## 2.0.2 (December 16th, 2007) ##
170   -
171   -* Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 *trek*
172   -
173   -* Correct empty response handling. #10445 *seangeo*
174   -
175   -
176   -## 2.0.1 (December 7th, 2007) ##
177   -
178   -* Don't cache net/http object so that ActiveResource is more thread-safe. Closes #10142 *kou*
179   -
180   -* Update XML documentation examples to include explicit type attributes. Closes #9754 *Josh Susser*
181   -
182   -* Added one-off declarations of mock behavior [David Heinemeier Hansson]. Example:
183   -
184   - Before:
185   - ActiveResource::HttpMock.respond_to do |mock|
186   - mock.get "/people/1.xml", {}, "<person><name>David</name></person>"
187   - end
188   -
189   - Now:
190   - ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>"
191   -
192   -* Added ActiveResource.format= which defaults to :xml but can also be set to :json [David Heinemeier Hansson]. Example:
193   -
194   - class Person < ActiveResource::Base
195   - self.site = "http://app/"
196   - self.format = :json
197   - end
198   -
199   - person = Person.find(1) # => GET http://app/people/1.json
200   - person.name = "David"
201   - person.save # => PUT http://app/people/1.json {name: "David"}
202   -
203   - Person.format = :xml
204   - person.name = "Mary"
205   - person.save # => PUT http://app/people/1.json <person><name>Mary</name></person>
206   -
207   -* Fix reload error when path prefix is used. #8727 *Ian Warshak*
208   -
209   -* Remove ActiveResource::Struct because it hasn't proven very useful. Creating a new ActiveResource::Base subclass is often less code and always clearer. #8612 *Josh Peek*
210   -
211   -* Fix query methods on resources. *Cody Fauser*
212   -
213   -* pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 *Eloy Duran*
214   -
215   -* Recognize and raise an exception on 405 Method Not Allowed responses. #7692 *Josh Peek*
216   -
217   -* Handle string and symbol param keys when splitting params into prefix params and query params.
218   -
219   - Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 })
220   -
221   -* Added find-one with symbol [David Heinemeier Hansson]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml
222   -
223   -* BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [David Heinemeier Hansson]. Changes:
224   -
225   - Person.find(:all, :title => "CEO") ...becomes: Person.find(:all, :params => { :title => "CEO" })
226   - Person.find(:managers) ...becomes: Person.find(:all, :from => :managers)
227   - Person.find("/companies/1/manager.xml") ...becomes: Person.find(:one, :from => "/companies/1/manager.xml")
228   -
229   -* Add support for setting custom headers per Active Resource model *Rick Olson*
230   -
231   - class Project
232   - headers['X-Token'] = 'foo'
233   - end
234   -
235   - \# makes the GET request with the custom X-Token header
236   - Project.find(:all)
237   -
238   -* Added find-by-path options to ActiveResource::Base.find [David Heinemeier Hansson]. Examples:
239   -
240   - employees = Person.find(:all, :from => "/companies/1/people.xml") # => GET /companies/1/people.xml
241   - manager = Person.find("/companies/1/manager.xml") # => GET /companies/1/manager.xml
242   -
243   -
244   -* Added support for using classes from within a single nested module [David Heinemeier Hansson]. Example:
245   -
246   - module Highrise
247   - class Note < ActiveResource::Base
248   - self.site = "http://37s.sunrise.i:3000"
249   - end
250   -
251   - class Comment < ActiveResource::Base
252   - self.site = "http://37s.sunrise.i:3000"
253   - end
254   - end
255   -
256   - assert_kind_of Highrise::Comment, Note.find(1).comments.first
257   -
258   -
259   -* Added load_attributes_from_response as a way of loading attributes from other responses than just create *David Heinemeier Hansson*
260   -
261   - class Highrise::Task < ActiveResource::Base
262   - def complete
263   - load_attributes_from_response(post(:complete))
264   - end
265   - end
266   -
267   - ...will set "done_at" when complete is called.
268   -
269   -
270   -* Added support for calling custom methods #6979 *rwdaigle*
271   -
272   - Person.find(:managers) # => GET /people/managers.xml
273   - Kase.find(1).post(:close) # => POST /kases/1/close.xml
274   -
275   -* Remove explicit prefix_options parameter for ActiveResource::Base#initialize. *Rick Olson*
276   - ActiveResource splits the prefix_options from it automatically.
277   -
278   -* Allow ActiveResource::Base.delete with custom prefix. *Rick Olson*
279   -
280   -* Add ActiveResource::Base#dup *Rick Olson*
281   -
282   -* Fixed constant warning when fetching the same object multiple times *David Heinemeier Hansson*
283   -
284   -* Added that saves which get a body response (and not just a 201) will use that response to update themselves *David Heinemeier Hansson*
285   -
286   -* Disregard namespaces from the default element name, so Highrise::Person will just try to fetch from "/people", not "/highrise/people" *David Heinemeier Hansson*
287   -
288   -* Allow array and hash query parameters. #7756 *Greg Spurrier*
289   -
290   -* Loading a resource preserves its prefix_options. #7353 *Ryan Daigle*
291   -
292   -* Carry over the convenience of #create from ActiveRecord. Closes #7340. *Ryan Daigle*
293   -
294   -* Increase ActiveResource::Base test coverage. Closes #7173, #7174 *Rich Collins*
295   -
296   -* Interpret 422 Unprocessable Entity as ResourceInvalid. #7097 *dkubb*
297   -
298   -* Mega documentation patches. #7025, #7069 *rwdaigle*
299   -
300   -* Base.exists?(id, options) and Base#exists? check whether the resource is found. #6970 *rwdaigle*
301   -
302   -* Query string support. *untext, Jeremy Kemper*
303   - # GET /forums/1/topics.xml?sort=created_at
304   - Topic.find(:all, :forum_id => 1, :sort => 'created_at')
305   -
306   -* Base#==, eql?, and hash methods. == returns true if its argument is identical to self or if it's an instance of the same class, is not new?, and has the same id. eql? is an alias for ==. hash delegates to id. *Jeremy Kemper*
307   -
308   -* Allow subclassed resources to share the site info *Rick Olson, Jeremy Kemper*
309   - d class BeastResource < ActiveResource::Base
310   - self.site = 'http://beast.caboo.se'
311   - end
312   -
313   - class Forum < BeastResource
314   - # taken from BeastResource
315   - # self.site = 'http://beast.caboo.se'
316   - end
317   -
318   - class Topic < BeastResource
319   - self.site += '/forums/:forum_id'
320   - end
321   -
322   -* Fix issues with ActiveResource collection handling. Closes #6291. *bmilekic*
323   -
324   -* Use attr_accessor_with_default to dry up attribute initialization. References #6538. *Stuart Halloway*
325   -
326   -* Add basic logging support for logging outgoing requests. *Jamis Buck*
327   -
328   -* Add Base.delete for deleting resources without having to instantiate them first. *Jamis Buck*
329   -
330   -* Make #save behavior mimic AR::Base#save (true on success, false on failure). *Jamis Buck*
331   -
332   -* Add Basic HTTP Authentication to ActiveResource (closes #6305). *jonathan*
333   -
334   -* Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID.
335   - By default, it extracts from the Location response header.
336   -
337   -* Optimistic locking: raise ActiveResource::ResourceConflict on 409 Conflict response. *Jeremy Kemper*
338   -
339   - # Example controller action
340   - def update
341   - @person.save!
342   - rescue ActiveRecord::StaleObjectError
343   - render :xml => @person.reload.to_xml, :status => '409 Conflict'
344   - end
345   -
346   -* Basic validation support *Rick Olson*
347   -
348   - Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors.
349   -
350   - render :xml => @person.errors.to_xml, :status => '400 Validation Error'
351   -
352   -* Deep hashes are converted into collections of resources. *Jeremy Kemper*
353   - Person.new :name => 'Bob',
354   - :address => { :id => 1, :city => 'Portland' },
355   - :contacts => [{ :id => 1 }, { :id => 2 }]
356   - Looks for Address and Contact resources and creates them if unavailable.
357   - So clients can fetch a complex resource in a single request if you e.g.
358   - render :xml => @person.to_xml(:include => [:address, :contacts])
359   - in your controller action.
360   -
361   -* Major updates *Rick Olson*
362   -
363   - * Add full support for find/create/update/destroy
364   - * Add support for specifying prefixes.
365   - * Allow overriding of element_name, collection_name, and primary key
366   - * Provide simpler HTTP mock interface for testing
367   -
368   - # rails routing code
369   - map.resources :posts do |post|
370   - post.resources :comments
371   - end
372   -
373   - # ActiveResources
374   - class Post < ActiveResource::Base
375   - self.site = "http://37s.sunrise.i:3000/"
376   - end
377   -
378   - class Comment < ActiveResource::Base
379   - self.site = "http://37s.sunrise.i:3000/posts/:post_id/"
380   - end
381   -
382   - @post = Post.find 5
383   - @comments = Comment.find :all, :post_id => @post.id
384   -
385   - @comment = Comment.new({:body => 'hello world'}, {:post_id => @post.id})
386   - @comment.save
387   -
388   -* Base.site= accepts URIs. 200...400 are valid response codes. PUT and POST request bodies default to ''. *Jeremy Kemper*
389   -
390   -* Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. *David Heinemeier Hansson*
20 activeresource/MIT-LICENSE
... ... @@ -1,20 +0,0 @@
1   -Copyright (c) 2006-2012 David Heinemeier Hansson
2   -
3   -Permission is hereby granted, free of charge, to any person obtaining
4   -a copy of this software and associated documentation files (the
5   -"Software"), to deal in the Software without restriction, including
6   -without limitation the rights to use, copy, modify, merge, publish,
7   -distribute, sublicense, and/or sell copies of the Software, and to
8   -permit persons to whom the Software is furnished to do so, subject to
9   -the following conditions:
10   -
11   -The above copyright notice and this permission notice shall be
12   -included in all copies or substantial portions of the Software.
13   -
14   -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15   -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16   -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17   -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18   -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19   -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20   -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
189 activeresource/README.rdoc
Source Rendered
... ... @@ -1,189 +0,0 @@
1   -= Active Resource
2   -
3   -Active Resource (ARes) connects business objects and Representational State Transfer (REST)
4   -web services. It implements object-relational mapping for REST web services to provide transparent
5   -proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing
6   -in ActionController::Resources).
7   -
8   -== Philosophy
9   -
10   -Active Resource attempts to provide a coherent wrapper object-relational mapping for REST
11   -web services. It follows the same philosophy as Active Record, in that one of its prime aims
12   -is to reduce the amount of code needed to map to these resources. This is made possible
13   -by relying on a number of code- and protocol-based conventions that make it easy for Active Resource
14   -to infer complex relations and structures. These conventions are outlined in detail in the documentation
15   -for ActiveResource::Base.
16   -
17   -== Overview
18   -
19   -Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database
20   -tables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result
21   -received and serialized into a usable Ruby object.
22   -
23   -== Download and installation
24   -
25   -The latest version of Active Support can be installed with RubyGems:
26   -
27   - % [sudo] gem install activeresource
28   -
29   -Source code can be downloaded as part of the Rails project on GitHub
30   -
31   -* https://github.com/rails/rails/tree/master/activeresource
32   -
33   -=== Configuration and Usage
34   -
35   -Putting Active Resource to use is very similar to Active Record. It's as simple as creating a model class
36   -that inherits from ActiveResource::Base and providing a <tt>site</tt> class variable to it:
37   -
38   - class Person < ActiveResource::Base
39   - self.site = "http://api.people.com:3000"
40   - end
41   -
42   -Now the Person class is REST enabled and can invoke REST services very similarly to how Active Record invokes
43   -life cycle methods that operate against a persistent store.
44   -
45   - # Find a person with id = 1
46   - ryan = Person.find(1)
47   - Person.exists?(1) # => true
48   -
49   -As you can see, the methods are quite similar to Active Record's methods for dealing with database
50   -records. But rather than dealing directly with a database record, you're dealing with HTTP resources (which may or may not be database records).
51   -
52   -==== Protocol
53   -
54   -Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing
55   -built into Action Controller but will also work with any other REST service that properly implements the protocol.
56   -REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification:
57   -
58   -* GET requests are used for finding and retrieving resources.
59   -* POST requests are used to create new resources.
60   -* PUT requests are used to update existing resources.
61   -* DELETE requests are used to delete resources.
62   -
63   -For more information on how this protocol works with Active Resource, see the ActiveResource::Base documentation;
64   -for more general information on REST web services, see the article here[http://en.wikipedia.org/wiki/Representational_State_Transfer].
65   -
66   -==== Find
67   -
68   -Find requests use the GET method and expect the XML form of whatever resource/resources is/are being requested. So,
69   -for a request for a single element, the XML of that item is expected in response:
70   -
71   - # Expects a response of
72   - #
73   - # <person><id type="integer">1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person>
74   - #
75   - # for GET http://api.people.com:3000/people/1.xml
76   - #
77   - ryan = Person.find(1)
78   -
79   -The XML document that is received is used to build a new object of type Person, with each
80   -XML element becoming an attribute on the object.
81   -
82   - ryan.is_a? Person # => true
83   - ryan.attribute1 # => 'value1'
84   -
85   -Any complex element (one that contains other elements) becomes its own object:
86   -
87   - # With this response:
88   - #
89   - # <person><id>1</id><attribute1>value1</attribute1><complex><attribute2>value2</attribute2></complex></person>
90   - #
91   - # for GET http://api.people.com:3000/people/1.xml
92   - #
93   - ryan = Person.find(1)
94   - ryan.complex # => <Person::Complex::xxxxx>
95   - ryan.complex.attribute2 # => 'value2'
96   -
97   -Collections can also be requested in a similar fashion
98   -
99   - # Expects a response of
100   - #
101   - # <people type="array">
102   - # <person><id type="integer">1</id><first>Ryan</first></person>
103   - # <person><id type="integer">2</id><first>Jim</first></person>
104   - # </people>
105   - #
106   - # for GET http://api.people.com:3000/people.xml
107   - #
108   - people = Person.all
109   - people.first # => <Person::xxx 'first' => 'Ryan' ...>
110   - people.last # => <Person::xxx 'first' => 'Jim' ...>
111   -
112   -==== Create
113   -
114   -Creating a new resource submits the XML form of the resource as the body of the request and expects
115   -a 'Location' header in the response with the RESTful URL location of the newly created resource. The
116   -id of the newly created resource is parsed out of the Location response header and automatically set
117   -as the id of the ARes object.
118   -
119   - # <person><first>Ryan</first></person>
120   - #
121   - # is submitted as the body on
122   - #
123   - # POST http://api.people.com:3000/people.xml
124   - #
125   - # when save is called on a new Person object. An empty response is
126   - # is expected with a 'Location' header value:
127   - #
128   - # Response (201): Location: http://api.people.com:3000/people/2
129   - #
130   - ryan = Person.new(:first => 'Ryan')
131   - ryan.new? # => true
132   - ryan.save # => true
133   - ryan.new? # => false
134   - ryan.id # => 2
135   -
136   -==== Update
137   -
138   -'save' is also used to update an existing resource and follows the same protocol as creating a resource
139   -with the exception that no response headers are needed -- just an empty response when the update on the
140   -server side was successful.
141   -
142   - # <person><first>Ryan</first></person>
143   - #
144   - # is submitted as the body on
145   - #
146   - # PUT http://api.people.com:3000/people/1.xml
147   - #
148   - # when save is called on an existing Person object. An empty response is
149   - # is expected with code (204)
150   - #
151   - ryan = Person.find(1)
152   - ryan.first # => 'Ryan'
153   - ryan.first = 'Rizzle'
154   - ryan.save # => true
155   -
156   -==== Delete
157   -
158   -Destruction of a resource can be invoked as a class and instance method of the resource.
159   -
160   - # A request is made to
161   - #
162   - # DELETE http://api.people.com:3000/people/1.xml
163   - #
164   - # for both of these forms. An empty response with
165   - # is expected with response code (200)
166   - #
167   - ryan = Person.find(1)
168   - ryan.destroy # => true
169   - ryan.exists? # => false
170   - Person.delete(2) # => true
171   - Person.exists?(2) # => false
172   -
173   -== License
174   -
175   -Active Support is released under the MIT license:
176   -
177   -* http://www.opensource.org/licenses/MIT
178   -
179   -== Support
180   -
181   -API documentation is at
182   -
183   -* http://api.rubyonrails.org
184   -
185   -Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
186   -
187   -* https://github.com/rails/rails/issues
188   -
189   -You can find more usage information in the ActiveResource::Base documentation.
66 activeresource/Rakefile
... ... @@ -1,66 +0,0 @@
1   -#!/usr/bin/env rake
2   -require 'rake/testtask'
3   -require 'rake/packagetask'
4   -require 'rubygems/package_task'
5   -
6   -desc "Default Task"
7   -task :default => [ :test ]
8   -
9   -# Run the unit tests
10   -
11   -Rake::TestTask.new { |t|
12   - t.libs << "test"
13   - t.pattern = 'test/**/*_test.rb'
14   - t.warning = true
15   - t.verbose = true
16   -}
17   -
18   -namespace :test do
19   - task :isolated do
20   - ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
21   - activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib"
22   - Dir.glob("test/**/*_test.rb").all? do |file|
23   - sh(ruby, '-w', "-Ilib:test:#{activesupport_path}", file)
24   - end or raise "Failures"
25   - end
26   -end
27   -
28   -spec = eval(File.read('activeresource.gemspec'))
29   -
30   -Gem::PackageTask.new(spec) do |p|
31   - p.gem_spec = spec
32   -end
33   -
34   -task :lines do
35   - lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
36   -
37   - FileList["lib/active_resource/**/*.rb"].each do |file_name|
38   - next if file_name =~ /vendor/
39   - f = File.open(file_name)
40   -
41   - while line = f.gets
42   - lines += 1
43   - next if line =~ /^\s*$/
44   - next if line =~ /^\s*#/
45   - codelines += 1
46   - end
47   - puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
48   -
49   - total_lines += lines
50   - total_codelines += codelines
51   -
52   - lines, codelines = 0, 0
53   - end
54   -
55   - puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
56   -end
57   -
58   -
59   -# Publishing ------------------------------------------------------
60   -
61   -desc "Release to gemcutter"
62   -task :release => :package do
63   - require 'rake/gemcutter'
64   - Rake::Gemcutter::Tasks.new(spec).define
65   - Rake::Task['gem:push'].invoke
66   -end
24 activeresource/activeresource.gemspec
... ... @@ -1,24 +0,0 @@
1   -version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
2   -
3   -Gem::Specification.new do |s|
4   - s.platform = Gem::Platform::RUBY
5   - s.name = 'activeresource'
6   - s.version = version
7   - s.summary = 'REST modeling framework (part of Rails).'
8   - s.description = 'REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models.'
9   -
10   - s.required_ruby_version = '>= 1.9.3'
11   -
12   - s.author = 'David Heinemeier Hansson'
13   - s.email = 'david@loudthinking.com'
14   - s.homepage = 'http://www.rubyonrails.org'
15   -
16   - s.files = Dir['CHANGELOG.md', 'MIT-LICENSE', 'README.rdoc', 'examples/**/*', 'lib/**/*']
17   - s.require_path = 'lib'
18   -
19   - s.extra_rdoc_files = %w( README.rdoc )
20   - s.rdoc_options.concat ['--main', 'README.rdoc']
21   -
22   - s.add_dependency('activesupport', version)
23   - s.add_dependency('activemodel', version)
24   -end
70 activeresource/examples/performance.rb
... ... @@ -1,70 +0,0 @@
1   -require 'rubygems'
2   -require 'active_resource'
3   -require 'benchmark'
4   -
5   -TIMES = (ENV['N'] || 10_000).to_i
6   -
7   -# deep nested resource
8   -attrs = {
9   - :id => 1,
10   - :name => 'Luis',
11   - :age => 21,
12   - :friends => [
13   - {
14   - :name => 'JK',
15   - :age => 24,
16   - :colors => ['red', 'green', 'blue'],
17   - :brothers => [
18   - {
19   - :name => 'Mateo',
20   - :age => 35,
21   - :children => [{ :name => 'Edith', :age => 5 }, { :name => 'Martha', :age => 4 }]
22   - },
23   - {
24   - :name => 'Felipe',
25   - :age => 33,
26   - :children => [{ :name => 'Bryan', :age => 1 }, { :name => 'Luke', :age => 0 }]
27   - }
28   - ]
29   - },
30   - {
31   - :name => 'Eduardo',
32   - :age => 20,
33   - :colors => [],
34   - :brothers => [
35   - {
36   - :name => 'Sebas',
37   - :age => 23,
38   - :children => [{ :name => 'Andres', :age => 0 }, { :name => 'Jorge', :age => 2 }]
39   - },
40   - {
41   - :name => 'Elsa',
42   - :age => 19,
43   - :children => [{ :name => 'Natacha', :age => 1 }]
44   - },
45   - {
46   - :name => 'Milena',
47   - :age => 16,
48   - :children => []
49   - }
50   - ]
51   - }
52   - ]
53   -}
54   -
55   -class Customer < ActiveResource::Base
56   - self.site = "http://37s.sunrise.i:3000"
57   -end
58   -
59   -module Nested
60   - class Customer < ActiveResource::Base
61   - self.site = "http://37s.sunrise.i:3000"
62   - end
63   -end
64   -
65   -Benchmark.bm(40) do |x|
66   - x.report('Model.new (instantiation)') { TIMES.times { Customer.new } }
67   - x.report('Nested::Model.new (instantiation)') { TIMES.times { Nested::Customer.new } }
68   - x.report('Model.new (setting attributes)') { TIMES.times { Customer.new attrs } }
69   - x.report('Nested::Model.new (setting attributes)') { TIMES.times { Nested::Customer.new attrs } }
70   -end
45 activeresource/lib/active_resource.rb
... ... @@ -1,45 +0,0 @@
1   -#--
2   -# Copyright (c) 2006-2012 David Heinemeier Hansson
3   -#
4   -# Permission is hereby granted, free of charge, to any person obtaining
5   -# a copy of this software and associated documentation files (the
6   -# "Software"), to deal in the Software without restriction, including
7   -# without limitation the rights to use, copy, modify, merge, publish,
8   -# distribute, sublicense, and/or sell copies of the Software, and to
9   -# permit persons to whom the Software is furnished to do so, subject to
10   -# the following conditions:
11   -#
12   -# The above copyright notice and this permission notice shall be
13   -# included in all copies or substantial portions of the Software.
14   -#
15   -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16   -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17   -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18   -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19   -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20   -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21   -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22   -#++
23   -
24   -activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
25   -$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
26   -
27   -activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
28   -$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
29   -
30   -require 'active_support'
31   -require 'active_model'
32   -require 'active_resource/version'
33   -
34   -module ActiveResource
35   - extend ActiveSupport::Autoload
36   -
37   - autoload :Base
38   - autoload :Connection
39   - autoload :CustomMethods
40   - autoload :Formats
41   - autoload :HttpMock
42   - autoload :Observing
43   - autoload :Schema
44   - autoload :Validations
45   -end
1,515 activeresource/lib/active_resource/base.rb
... ... @@ -1,1515 +0,0 @@
1   -require 'active_support'
2   -require 'active_support/core_ext/class/attribute_accessors'
3   -require 'active_support/core_ext/class/attribute'
4   -require 'active_support/core_ext/hash/indifferent_access'
5   -require 'active_support/core_ext/kernel/reporting'
6   -require 'active_support/core_ext/module/delegation'
7   -require 'active_support/core_ext/module/aliasing'
8   -require 'active_support/core_ext/object/blank'
9   -require 'active_support/core_ext/object/to_query'
10   -require 'active_support/core_ext/object/duplicable'
11   -require 'set'
12   -require 'uri'
13   -
14   -require 'active_support/core_ext/uri'
15   -require 'active_resource/exceptions'
16   -require 'active_resource/connection'
17   -require 'active_resource/formats'
18   -require 'active_resource/schema'
19   -require 'active_resource/log_subscriber'
20   -
21   -module ActiveResource
22   - # ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application.
23   - #
24   - # For an outline of what Active Resource is capable of, see its {README}[link:files/activeresource/README_rdoc.html].
25   - #
26   - # == Automated mapping
27   - #
28   - # Active Resource objects represent your RESTful resources as manipulatable Ruby objects. To map resources
29   - # to Ruby objects, Active Resource only needs a class name that corresponds to the resource name (e.g., the class
30   - # Person maps to the resources people, very similarly to Active Record) and a +site+ value, which holds the
31   - # URI of the resources.
32   - #
33   - # class Person < ActiveResource::Base
34   - # self.site = "https://api.people.com"
35   - # end
36   - #
37   - # Now the Person class is mapped to RESTful resources located at <tt>https://api.people.com/people/</tt>, and
38   - # you can now use Active Resource's life cycle methods to manipulate resources. In the case where you already have
39   - # an existing model with the same name as the desired RESTful resource you can set the +element_name+ value.
40   - #
41   - # class PersonResource < ActiveResource::Base
42   - # self.site = "https://api.people.com"
43   - # self.element_name = "person"
44   - # end
45   - #
46   - # If your Active Resource object is required to use an HTTP proxy you can set the +proxy+ value which holds a URI.
47   - #
48   - # class PersonResource < ActiveResource::Base
49   - # self.site = "https://api.people.com"
50   - # self.proxy = "https://user:password@proxy.people.com:8080"
51   - # end
52   - #
53   - #
54   - # == Life cycle methods
55   - #
56   - # Active Resource exposes methods for creating, finding, updating, and deleting resources
57   - # from REST web services.
58   - #
59   - # ryan = Person.new(:first => 'Ryan', :last => 'Daigle')
60   - # ryan.save # => true
61   - # ryan.id # => 2
62   - # Person.exists?(ryan.id) # => true
63   - # ryan.exists? # => true
64   - #
65   - # ryan = Person.find(1)
66   - # # Resource holding our newly created Person object
67   - #
68   - # ryan.first = 'Rizzle'
69   - # ryan.save # => true
70   - #
71   - # ryan.destroy # => true
72   - #
73   - # As you can see, these are very similar to Active Record's life cycle methods for database records.
74   - # You can read more about each of these methods in their respective documentation.
75   - #
76   - # === Custom REST methods
77   - #
78   - # Since simple CRUD/life cycle methods can't accomplish every task, Active Resource also supports
79   - # defining your own custom REST methods. To invoke them, Active Resource provides the <tt>get</tt>,
80   - # <tt>post</tt>, <tt>put</tt> and <tt>\delete</tt> methods where you can specify a custom REST method
81   - # name to invoke.
82   - #
83   - # # POST to the custom 'register' REST method, i.e. POST /people/new/register.json.
84   - # Person.new(:name => 'Ryan').post(:register)
85   - # # => { :id => 1, :name => 'Ryan', :position => 'Clerk' }
86   - #
87   - # # PUT an update by invoking the 'promote' REST method, i.e. PUT /people/1/promote.json?position=Manager.
88   - # Person.find(1).put(:promote, :position => 'Manager')
89   - # # => { :id => 1, :name => 'Ryan', :position => 'Manager' }
90   - #
91   - # # GET all the positions available, i.e. GET /people/positions.json.
92   - # Person.get(:positions)
93   - # # => [{:name => 'Manager'}, {:name => 'Clerk'}]
94   - #
95   - # # DELETE to 'fire' a person, i.e. DELETE /people/1/fire.json.
96   - # Person.find(1).delete(:fire)
97   - #
98   - # For more information on using custom REST methods, see the
99   - # ActiveResource::CustomMethods documentation.
100   - #
101   - # == Validations
102   - #
103   - # You can validate resources client side by overriding validation methods in the base class.
104   - #
105   - # class Person < ActiveResource::Base
106   - # self.site = "https://api.people.com"
107   - # protected
108   - # def validate
109   - # errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/
110   - # end
111   - # end
112   - #
113   - # See the ActiveResource::Validations documentation for more information.
114   - #
115   - # == Authentication
116   - #
117   - # Many REST APIs require authentication. The HTTP spec describes two ways to
118   - # make requests with a username and password (see RFC 2617).
119   - #
120   - # Basic authentication simply sends a username and password along with HTTP
121   - # requests. These sensitive credentials are sent unencrypted, visible to
122   - # any onlooker, so this scheme should only be used with SSL.
123   - #
124   - # Digest authentication sends a crytographic hash of the username, password,
125   - # HTTP method, URI, and a single-use secret key provided by the server.
126   - # Sensitive credentials aren't visible to onlookers, so digest authentication
127   - # doesn't require SSL. However, this doesn't mean the connection is secure!
128   - # Just the username and password.
129   - #
130   - # (You really, really want to use SSL. There's little reason not to.)
131   - #
132   - # === Picking an authentication scheme
133   - #
134   - # Basic authentication is the default. To switch to digest authentication,
135   - # set +auth_type+ to +:digest+:
136   - #
137   - # class Person < ActiveResource::Base
138   - # self.auth_type = :digest
139   - # end
140   - #
141   - # === Setting the username and password
142   - #
143   - # Set +user+ and +password+ on the class, or include them in the +site+ URL.
144   - #
145   - # class Person < ActiveResource::Base
146   - # # Set user and password directly:
147   - # self.user = "ryan"
148   - # self.password = "password"
149   - #
150   - # # Or include them in the site:
151   - # self.site = "https://ryan:password@api.people.com"
152   - # end
153   - #
154   - # === Certificate Authentication
155   - #
156   - # You can also authenticate using an X509 certificate. <tt>See ssl_options=</tt> for all options.
157   - #
158   - # class Person < ActiveResource::Base
159   - # self.site = "https://secure.api.people.com/"
160   - #
161   - # File.open(pem_file_path, 'rb') do |pem_file|
162   - # self.ssl_options = {
163   - # cert: OpenSSL::X509::Certificate.new(pem_file),
164   - # key: OpenSSL::PKey::RSA.new(pem_file),
165   - # ca_path: "/path/to/OpenSSL/formatted/CA_Certs",
166   - # verify_mode: OpenSSL::SSL::VERIFY_PEER }
167   - # end
168   - # end
169   - #
170   - #
171   - # == Errors & Validation
172   - #
173   - # Error handling and validation is handled in much the same manner as you're used to seeing in
174   - # Active Record. Both the response code in the HTTP response and the body of the response are used to
175   - # indicate that an error occurred.
176   - #
177   - # === Resource errors
178   - #
179   - # When a GET is requested for a resource that does not exist, the HTTP <tt>404</tt> (Resource Not Found)
180   - # response code will be returned from the server which will raise an ActiveResource::ResourceNotFound
181   - # exception.
182   - #
183   - # # GET https://api.people.com/people/999.json
184   - # ryan = Person.find(999) # 404, raises ActiveResource::ResourceNotFound
185   - #
186   - #
187   - # <tt>404</tt> is just one of the HTTP error response codes that Active Resource will handle with its own exception. The
188   - # following HTTP response codes will also result in these exceptions:
189   - #
190   - # * 200..399 - Valid response. No exceptions, other than these redirects:
191   - # * 301, 302, 303, 307 - ActiveResource::Redirection
192   - # * 400 - ActiveResource::BadRequest
193   - # * 401 - ActiveResource::UnauthorizedAccess
194   - # * 403 - ActiveResource::ForbiddenAccess
195   - # * 404 - ActiveResource::ResourceNotFound
196   - # * 405 - ActiveResource::MethodNotAllowed
197   - # * 409 - ActiveResource::ResourceConflict
198   - # * 410 - ActiveResource::ResourceGone
199   - # * 422 - ActiveResource::ResourceInvalid (rescued by save as validation errors)
200   - # * 401..499 - ActiveResource::ClientError
201   - # * 500..599 - ActiveResource::ServerError
202   - # * Other - ActiveResource::ConnectionError
203   - #
204   - # These custom exceptions allow you to deal with resource errors more naturally and with more precision
205   - # rather than returning a general HTTP error. For example:
206   - #
207   - # begin
208   - # ryan = Person.find(my_id)
209   - # rescue ActiveResource::ResourceNotFound
210   - # redirect_to :action => 'not_found'
211   - # rescue ActiveResource::ResourceConflict, ActiveResource::ResourceInvalid
212   - # redirect_to :action => 'new'
213   - # end
214   - #
215   - # When a GET is requested for a nested resource and you don't provide the prefix_param
216   - # an ActiveResource::MissingPrefixParam will be raised.
217   - #
218   - # class Comment < ActiveResource::Base
219   - # self.site = "https://someip.com/posts/:post_id"
220   - # end
221   - #
222   - # Comment.find(1)
223   - # # => ActiveResource::MissingPrefixParam: post_id prefix_option is missing
224   - #
225   - # === Validation errors
226   - #
227   - # Active Resource supports validations on resources and will return errors if any of these validations fail
228   - # (e.g., "First name can not be blank" and so on). These types of errors are denoted in the response by
229   - # a response code of <tt>422</tt> and an XML or JSON representation of the validation errors. The save operation will
230   - # then fail (with a <tt>false</tt> return value) and the validation errors can be accessed on the resource in question.
231   - #
232   - # ryan = Person.find(1)
233   - # ryan.first # => ''
234   - # ryan.save # => false
235   - #
236   - # # When
237   - # # PUT https://api.people.com/people/1.xml
238   - # # or
239   - # # PUT https://api.people.com/people/1.json
240   - # # is requested with invalid values, the response is:
241   - # #