Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/branches/2-1-caching/activeresource/CHANGELOG

Revision 8391, 8.3 kB (checked in by david, 1 year ago)

Work branch

Line 
1 *SVN*
2
3 * Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 [trek]
4
5 * Correct empty response handling.  #10445 [seangeo]
6
7
8 *2.0.1* (December 7th, 2007)
9
10 * Don't cache net/http object so that ActiveResource is more thread-safe.  Closes #10142 [kou]
11
12 * Update XML documentation examples to include explicit type attributes. Closes #9754 [hasmanyjosh]
13
14 * Added one-off declarations of mock behavior [DHH]. Example:
15
16     Before:
17       ActiveResource::HttpMock.respond_to do |mock|
18         mock.get "/people/1.xml", {}, "<person><name>David</name></person>"
19       end
20      
21     Now:
22       ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>"
23
24 * Added ActiveResource.format= which defaults to :xml but can also be set to :json [DHH]. Example:
25
26     class Person < ActiveResource::Base
27       self.site   = "http://app/"
28       self.format = :json
29     end
30    
31     person = Person.find(1) # => GET http://app/people/1.json
32     person.name = "David"
33     person.save             # => PUT http://app/people/1.json {name: "David"}
34    
35     Person.format = :xml
36     person.name = "Mary"
37     person.save             # => PUT http://app/people/1.json <person><name>Mary</name></person>   
38
39 * Fix reload error when path prefix is used.  #8727 [Ian Warshak]
40
41 * 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]
42
43 * Fix query methods on resources. [Cody Fauser]
44
45 * pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 [alloy]
46
47 * Recognize and raise an exception on 405 Method Not Allowed responses.  #7692 [Josh Peek]
48
49 * Handle string and symbol param keys when splitting params into prefix params and query params.
50
51     Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 })
52
53 * Added find-one with symbol [DHH]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml
54
55 * BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [DHH]. Changes:
56
57     Person.find(:all, :title => "CEO")      ...becomes: Person.find(:all, :params => { :title => "CEO" })
58     Person.find(:managers)                  ...becomes: Person.find(:all, :from => :managers)
59     Person.find("/companies/1/manager.xml") ...becomes: Person.find(:one, :from => "/companies/1/manager.xml")
60
61 * Add support for setting custom headers per Active Resource model [Rick]
62
63   class Project
64     headers['X-Token'] = 'foo'
65   end
66  
67   # makes the GET request with the custom X-Token header
68   Project.find(:all)
69
70 * Added find-by-path options to ActiveResource::Base.find [DHH]. Examples:
71
72     employees = Person.find(:all, :from => "/companies/1/people.xml") # => GET /companies/1/people.xml
73     manager   = Person.find("/companies/1/manager.xml")               # => GET /companies/1/manager.xml
74
75
76 * Added support for using classes from within a single nested module [DHH]. Example:
77
78     module Highrise
79       class Note < ActiveResource::Base
80         self.site = "http://37s.sunrise.i:3000"
81       end
82
83       class Comment < ActiveResource::Base
84         self.site = "http://37s.sunrise.i:3000"
85       end
86     end
87
88   assert_kind_of Highrise::Comment, Note.find(1).comments.first
89    
90
91 * Added load_attributes_from_response as a way of loading attributes from other responses than just create [DHH]
92
93     class Highrise::Task < ActiveResource::Base
94       def complete
95         load_attributes_from_response(post(:complete))
96       end
97     end
98
99   ...will set "done_at" when complete is called.
100
101
102 * Added support for calling custom methods #6979 [rwdaigle]
103
104     Person.find(:managers)    # => GET /people/managers.xml
105     Kase.find(1).post(:close) # => POST /kases/1/close.xml
106
107 * Remove explicit prefix_options parameter for ActiveResource::Base#initialize. [Rick]
108   ActiveResource splits the prefix_options from it automatically.
109
110 * Allow ActiveResource::Base.delete with custom prefix. [Rick]
111
112 * Add ActiveResource::Base#dup [Rick]
113
114 * Fixed constant warning when fetching the same object multiple times [DHH]
115
116 * Added that saves which get a body response (and not just a 201) will use that response to update themselves [DHH]
117
118 * Disregard namespaces from the default element name, so Highrise::Person will just try to fetch from "/people", not "/highrise/people" [DHH]
119
120 * Allow array and hash query parameters.  #7756 [Greg Spurrier]
121
122 * Loading a resource preserves its prefix_options.  #7353 [Ryan Daigle]
123
124 * Carry over the convenience of #create from ActiveRecord.  Closes #7340.  [Ryan Daigle]
125
126 * Increase ActiveResource::Base test coverage.  Closes #7173, #7174 [Rich Collins]
127
128 * Interpret 422 Unprocessable Entity as ResourceInvalid.  #7097 [dkubb]
129
130 * Mega documentation patches. #7025, #7069 [rwdaigle]
131
132 * Base.exists?(id, options) and Base#exists? check whether the resource is found.  #6970 [rwdaigle]
133
134 * Query string support.  [untext, Jeremy Kemper]
135     # GET /forums/1/topics.xml?sort=created_at
136     Topic.find(:all, :forum_id => 1, :sort => 'created_at')
137
138 * 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]
139
140 * Allow subclassed resources to share the site info [Rick, Jeremy Kemper]
141 d
142     class BeastResource < ActiveResource::Base
143       self.site = 'http://beast.caboo.se'
144     end
145
146     class Forum < BeastResource
147       # taken from BeastResource
148       # self.site = 'http://beast.caboo.se'
149     end
150
151     class Topic < BeastResource
152       self.site += '/forums/:forum_id'
153     end
154
155 * Fix issues with ActiveResource collection handling.  Closes #6291. [bmilekic]
156
157 * Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway]
158
159 * Add basic logging support for logging outgoing requests. [Jamis Buck]
160
161 * Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck]
162
163 * Make #save behavior mimic AR::Base#save (true on success, false on failure). [Jamis Buck]
164
165 * Add Basic HTTP Authentication to ActiveResource (closes #6305). [jonathan]
166
167 * Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID.
168   By default, it extracts from the Location response header.
169
170 * Optimistic locking: raise ActiveResource::ResourceConflict on 409 Conflict response. [Jeremy Kemper]
171
172     # Example controller action
173     def update
174       @person.save!
175     rescue ActiveRecord::StaleObjectError
176       render :xml => @person.reload.to_xml, :status => '409 Conflict'
177     end
178
179 * Basic validation support [Rick Olson]
180
181   Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors. 
182  
183     render :xml => @person.errors.to_xml, :status => '400 Validation Error'
184
185 * Deep hashes are converted into collections of resources.  [Jeremy Kemper]
186     Person.new :name => 'Bob',
187                :address => { :id => 1, :city => 'Portland' },
188                :contacts => [{ :id => 1 }, { :id => 2 }]
189   Looks for Address and Contact resources and creates them if unavailable.
190   So clients can fetch a complex resource in a single request if you e.g.
191     render :xml => @person.to_xml(:include => [:address, :contacts])
192   in your controller action.
193
194 * Major updates [Rick Olson]
195
196   * Add full support for find/create/update/destroy
197   * Add support for specifying prefixes.
198   * Allow overriding of element_name, collection_name, and primary key
199   * Provide simpler HTTP mock interface for testing
200  
201     # rails routing code
202     map.resources :posts do |post|
203       post.resources :comments
204     end
205    
206     # ActiveResources
207     class Post < ActiveResource::Base
208       self.site = "http://37s.sunrise.i:3000/"
209     end
210
211     class Comment < ActiveResource::Base
212       self.site = "http://37s.sunrise.i:3000/posts/:post_id/"
213     end
214    
215     @post     = Post.find 5
216     @comments = Comment.find :all, :post_id => @post.id
217
218     @comment  = Comment.new({:body => 'hello world'}, {:post_id => @post.id})
219     @comment.save
220
221 * Base.site= accepts URIs. 200...400 are valid response codes. PUT and POST request bodies default to ''. [Jeremy Kemper]
222
223 * Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [DHH]
Note: See TracBrowser for help on using the browser.