Ruby OData Update v0.0.7

July 6, 2010 • Damien White

OData_logo_MS_small I  just wanted to give an update on the ruby_odata progress.  If you don’t know about ruby_odata or want a refresher, I blogged about it a few weeks ago.  Anyway, I just released a new version of the gem, v0.0.7.  With this new version, you can now perform batch saves (multiple adds, deletes, and updates) and types are being supported.  The library is getting more mature with each revision.  Below is the state of the current gem:

  • dynamic methods are available after you instantiate the service.  You can chain query operations like **order_by**, **filter**, **expand**, etc. on to the dynamic methods.  
  • For querying, $orderby, $top, $skip, $filter, and $expand are supported.  These are represented by the methods order_by, top, skip, filter, and **expand **(respectively) on the OData::QueryBuilder class (which is returned from the dynamic collection methods), for example: svc.Products.top(10).
     
  • The ability to add entities.  **AddTo** dynamic methods are available after you instantiate the service, allowing you to pass new entities to the methods.  
  • The ability to update entities though the update_object method on the OData::Service.
     
  • The ability to delete entities though the delete_object method on the OData::Service.
     
  • The ability to batch saves, which allows you to pass multiple objects to be added, updated, or deleted and have them persisted as a batch when you call the save_changes method on the OData::Service.  Note that with batch saves, the changes either complete or fail as a batch.
     
  • Explicit data type support for the following: (Everything outside of this list currently is represented as a string.)
    • Edm.Int16
    • Edm.Int32
    • Edm.Int64
    • Edm.Decimal
    • Edm.DateTime – Note that DateTime is a bit odd.  There’s no time zone data passed from OData services (at least not with WCF Data Services), so it is assumed that the time zone is UTC for all DateTime types.
       
  • Support for Complex Types – From OData.org: “**Complex Types** are structured types also consisting of a list of properties but with no key, and thus can only exist as a property of a containing entity or as a temporary value.”  You’ll typically see these to logically group properties together.  For example, with the Netflix service, they expose a BoxArt complex type on a Title.  The BoxArt type consists of 3 properties, SmallUrl, MediumUrl, LargeUrl.  This makes accessing these clearer and cleaner, for example movie.BoxArt.MediumUrl.
     
  • Works with Ruby 1.8.7 and Ruby 1.9.1.  It also works with ActiveSupport 3.0.0.beta4.  These were tested on Windows due to using WCF Data Services for the test suite, although, if something Ruby works in Windows there is a good chance everything should be fine on Mac or Linux as well.  I could always change the test URLs to point at a remote machine to do my testing on a Mac, but I wish there was an OData producer like WCF Data Services that would work with ActiveRecord (or similar).

Posted in odata, ruby, ruby_odata and tagged with OData, Ruby, WCF

Damien White

I am a software architect with over 16 years of experience. I simply love coding! I have a driving passion for computers and software development, and a thirst for knowledge that just cannot be quenched. I'm happy to share what I know in my quest to learn as much as possible. I focus most of my time on web development using Ruby on Rails, Ember.js, and ASP.NET MVC.

comments powered by Disqus