Hello,
I''m currently working on some code to support ActiveResource in
RubyCocoa with Cocoa Bindings.
I have already written (most) of the glue for ActiveRecord, so obviously
I want to keep my code DRY and reuse most of the glue code.
During this I noticed that there''s a difference in argument naming
between the two.
In ActiveRecord when using the find class method you would use
:conditions to, well you know set the conditions :)
e.g.: Foo.find :all, :conditions => { :bar => ''baz'' }
However in ActiveResource you are supposed to use the :params key.
e.g.: Foo.find :all, :params => { :bar => ''baz'' }
I can understand how you would call them :params in ActiveResource
because they are going to be send as parameters. But I find it more
consistent if at least ActiveResource would also accept the :conditions
key. This would also allow me to use ducktyping on them, which is what
I''m doing.
So atm I''ve added my own workaround to ActiveResource::Base, but I
could
whip up a patch for it, that would either rename the :params to
:conditions key, or simply duplicate them like in my workaround, if
necessary?
class << self
alias_method :__find__, :find
def find(*args)
args[1][:params] = args[1][:conditions] unless args[1].nil?
__find__(*args)
end
end
Cheers,
Eloy
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---