The next version of HyperResource to be released will be 0.9.0. This is a big jump from the current 0.2.1, but it better reflects HR's closeness to 1.0-quality and intentions to standardize its interface for a while. (And anyway, there were four versions before 0.1 that no one saw but me.)
I'm going to leave this pull request open, in case people would like to watch progress.
Changes from 0.2.1:
Automatic method creation doesn't happen anymore.method_missing now handles all method calls for link, object, and attribute names. Creating instance methods on the resource's class was error-prone, it could violate the principle of HATEOAS by misleading the end user about links or attributes or objects that don't exist on a particular resource, and most egregiously of all, it completely busts Ruby's method resolution cache, causing absolutely all method calls to incur a ~1ms penalty the first time they're called after the cache is cleared. method_missing has always done a fine job; removing _hr_create_methods! improves real world performance and simplifies the HR code.
Resource instantiation is cleaner. Previously, calling an HTTP method on a HyperResource would change its state, then return a different object. Now HTTP is delegated to Link objects, and HyperResource#to_link handles instantiating a link from a resource (in the background, of course). The resulting logic is cleaner, inheritance is easier to track, and object state is easier to comprehend.
#create and #update are deprecated. Just use #post, #put, or #patch.
Introducing hostmasked config variables. HyperResource 0.9 adds the feature that configuration parameters (namespace, auth, header, faraday_options, and default_attributes) can now be scoped by hostmask. This opens the way for seamless integration with an ecosystem of separate APIs which point to each others' resources (well... seamless for the client, anyway). Look at test/live/two_server_test.rb to see what it's all about.
(Side note: the hostmasking logic became heavy enough that I spun it out into its own gem, FuzzyURL. Check it out if you like non-strict URL parsing, construction, or wildcard matching.)
The next version of HyperResource to be released will be 0.9.0. This is a big jump from the current 0.2.1, but it better reflects HR's closeness to 1.0-quality and intentions to standardize its interface for a while. (And anyway, there were four versions before 0.1 that no one saw but me.)
I'm going to leave this pull request open, in case people would like to watch progress.
Changes from 0.2.1:
method_missing
now handles all method calls for link, object, and attribute names. Creating instance methods on the resource's class was error-prone, it could violate the principle of HATEOAS by misleading the end user about links or attributes or objects that don't exist on a particular resource, and most egregiously of all, it completely busts Ruby's method resolution cache, causing absolutely all method calls to incur a ~1ms penalty the first time they're called after the cache is cleared.method_missing
has always done a fine job; removing_hr_create_methods!
improves real world performance and simplifies the HR code.test/live/two_server_test.rb
to see what it's all about.(Side note: the hostmasking logic became heavy enough that I spun it out into its own gem, FuzzyURL. Check it out if you like non-strict URL parsing, construction, or wildcard matching.)