- Wrapped ActiveRecord? and ActiveResource? in an instance attribute called @storage. The storage is dinamically chosen in the TaliaCore::Resource#factory method.
- Wrapping the storage in an instance attribute creates a syntactic issue: i.e. to refer ActiveRecord? methods we should use: resource.storage.save. This issue can be solved implementing method_missing.
- The previous workaround works only for add missing methods, but not for override Ruby methods.
I.E.
book = Book.find(:first) puts book.id #=> warning: Object#id will be deprecated; use Object#object_id
The method called is Object#id (deprecated) instead of ActiveRecord#id
- Wrapping the storage is useful to inject instance methods, but useless for static methods. Since the class methods have to be ready before the choose between local and remote (factory method).
I.E. The typical usage for find method is:
book = Book.find(:first)
There are two issues:
+ The find method ins't available, cause we haven't injected any code.
+ The search process is local or remote?
A solution can be override the find method and create a new convention: All searches are local.
For a remote search we can use the following syntax:
book = Book.find(:first, :remote => true)
- The find implementation has a downside: the @storage attribute will not be instantiate, since the factory method isn't called.
A solution can be the after_find callback, but for some strange reason it is not called.
