Commits on Aug 23, 2010
  1. @qoyyim-at-kiranatama

    using nokogiri to extract not only xml child but also xml attribute

    add :put and :delete params in find options
    edit readme
    qoyyim-at-kiranatama committed Aug 23, 2010
Commits on Aug 20, 2010
  1. change find_every to use post params to post data

    unknown committed Aug 20, 2010
Commits on Jan 14, 2010
  1. Add before/after create callbacks

    add before_create/after_create callbacks.
    Warning: Not well tested!
    taryneast committed Jan 14, 2010
Commits on Oct 29, 2009
  1. Count-method fix: respond better to "find with id = 'count'" response

    A RESTful interface may easily accept the path: /widgets/count.xml
    and turn it into:
      find widgets with the id = "count"
      oops, can't find one... return
    If it returns a 404, we already catch this... this is the equivalent to a
    find_single or find_by_id request... but some interfaces will convert the
    above into a 'find all matching' request, where the correct response is a
    So we don't get an exception, just an object that doesn't respond to the
    'count' method (eg an empty array).
    This fix - checks for that.
    (phew, long explanation for a simple fix!) :)
    taryneast committed Oct 29, 2009
  2. Update to the raw_data to ensure format is reset back.

    The bug was that if we make a request on an object in a new format - we set
    the format to, say, 'pdf'. Then, if we get a 404 or 500 etc on the call for
    this pdf - we could escape without resetting the format back to the
    original (eg xml)... which means every call after then will try (and fail)
    to decode from pdf...
    This change will ensure that we reset the format back to the original
    format regardless of the success of the get.
    taryneast committed Oct 29, 2009
Commits on Sep 18, 2009
  1. Bugfix: arrayify, not arrayify!

    taryneast committed Sep 18, 2009
Commits on Sep 4, 2009
  1. Fix for latest stable version of rails' validations

    The current version of "generate_message" does something weird to collect up
    the superclasses of active record - using a method called self_and_descendants_from_active_record
    obviously this is named inappropriately for general piracy and use
    within HyRes... but no choice but to cover it for the meantime.
    This fix will work even if it's not pretty and largely irrelevant to how
    HyRes works atm.
    taryneast committed Sep 4, 2009
Commits on Sep 2, 2009
  1. Update to README

    Added a couple more TODOs and to update the text to be a bit more recent.
    Also added a section on the work pulling HyRes into Rails 3.0
    taryneast committed Sep 2, 2009
  2. Removal of an unsued line == cruft!

    taryn committed Sep 2, 2009
  3. Add the sadly-overlooked has_one method

    Pointed out to me by philister - I'd implemented the has_many alias, but not
    has_one. now added.
    taryn committed Sep 2, 2009
Commits on Jul 2, 2009
  1. Add in my acts_like? monkeypatches for Array and Hash...

    These should be in Rails core extensions...
    taryn committed Jul 2, 2009
  2. Added some defaults and sanity checks to split_options

    Return quickly on trivial case (no options)
    Check that options is a hash and boot us out if it isn't
    Don't explode on nil 'keep_if_nil' option
    taryn committed Jul 2, 2009
Commits on Jun 19, 2009
  1. Bugfix: initialize not instantiate!

    I was accidentally stack-level-overrunning because I wasn't removing the
    "initialize_by" part of "find_or_initialize_by" before calling it as a
    "finder method"...
    taryn committed Jun 19, 2009
  2. raw_data lets us at the raw response without decoding.

    add a raw_data method that lets us pull the raw_data of the response for
    users - without decoding it from the given format.
    This lets us, say, pull the actual PDF data of a pdf-format request and
    stream it directly to the user.
    taryn committed Jun 19, 2009
Commits on Jun 17, 2009
  1. Hack to fix primary_key for non-integer primary keys.

    I still can't find where the 'id' field is being to_ied - and I've spent way
    too long looking for it. Somehow it happens during load(attributes).
    So I've just added a hack that saves the after_typecast primary key during
    the load... and forces it back into the @attributes['id'] field.
    This seems to get around the issue I was having when using a *string*
    primary_key (a uuid). So now e can confidently use: primary_key = :uuid and
    have it *just work*.
    Note - for now you have to include :uuid in the columns!
    taryn committed Jun 17, 2009
Commits on Jun 16, 2009
  1. to_params-ification done so primary_key = :uuid should work now

    There were a number of references directly to ".id" in the code. These have
    all been replaced by "to_param" so we can use the pre-existing ARes
    primary_key function.
    The "id_from_response" was also failing because it didn't reference the
    primary_key, but "id".
    Also updated README to better comment the example and give an idea of a
    callback to generate a uuid...
    taryn committed Jun 16, 2009
  2. Prettify with arrayify.

    taryn committed Jun 16, 2009
  3. Big change - encode (eg create/update) only sends attributes we know …

    This change may well affect other projects that use HyRes, but I was sick of
    doing a create and having all of my accessors and has_many associations
    being sent along with the "real" attributes. The remote API was getting
    If you have all of your remote columns declared (including belongs_to
    association ids) then you won't have a problem.
    This is roughly equivalent to the internal ActiveRecord methods of
    "validate_find_options" (though we're sending them, rather than using them
    to fetch).
    taryn committed Jun 16, 2009
Commits on Jun 12, 2009
  1. Some bugfixes to get the dynamic creator working nicely.

    Note-to-self: tests against all the code before assuming it works! :P
    taryn committed Jun 12, 2009
  2. No longer need the non-rdoc version.

    taryn committed Jun 12, 2009
  3. Update Dynamic finders to ActiveRecord style and add instantiators

    Yay - parity with ActiveRecord on Dynamic Finders.
    We can now not only do find_<scope>_by_X but can also pass in any number of
    find_by_X_and_Y_and_Z... etc
    Also added instantiators so can also do:
    find_or_instantiate_by_X and find_or_create_by_X and find_or_create_by_X!
    In the process of adding the last, also added create!
    Updated README to reflect new changes - including more examples of use and
    removal of both the related TODOs
    taryn committed Jun 12, 2009
  4. Updated README in line with current features.

    Added a small section on dynamic finders explaining the current limitation
    of one attribute only.
    Updated TODOs - we now have a collection-getter for associations - so that
    no longer breaks.
    Added some extra examples, and fixed a bug in one (count requires
    ":conditions =>  conds", not just the bare conds.
    taryn committed Jun 12, 2009
Commits on Jun 11, 2009
  1. Nested params can be taken from attributes.

    As an attribute for a nested path is passed in - we should save it into the
    This allows us to do:
    thing =[:thing])
    thing.user_id =!
    or even
    thing =[:thing])
    thing.user = current_user!
    taryn committed Jun 11, 2009
  2. Bugfixes for count-updates.

    Note to self: always check that your changes haven't broken the rest of the
    code before you check in :P
    It was working now for models without a count-route, but had broken models
    that have a count-path :P
    Then it rebroke for models without a count-path because a Rails-based API
    silently swallows a lack of count-route by looking for a model with the id
    of 'count' :P
    I think this is poor behaviour on the part of rails... but anyway...
    Also fixed some bugs from collection_path that I had never hit before
    because I'd never used that code :P
    taryn committed Jun 11, 2009
  3. Added description of count and your API

    It's complicated enough that it needs a section of its own to explain how to
    use it.
    taryn committed Jun 11, 2009
  4. Better-working self.count -> fallback optin now works properly.

    Fallback option on count was not being called properly in the case where we
    receive a server error (eg route-not-found). Now it is, and is correctly
    defaulting to the index using the original args.
    taryn committed Jun 11, 2009
  5. Bugfix to from_xml when an instance passed instead of xml

    when from_xml-ing, if we haven't actually passed in xml - but have passed an
    instance of ourselves... we don't need to from_xml ourselves.
    This might happen on reload of an instance that has already from_xmled some
    Also - a record should be able to instantiate from an instance of itself by
    taryn committed Jun 11, 2009
Commits on Jun 8, 2009
  1. Add from_xml that instantiates the records in the xml.

    "decode" doesn't appear to do that - it possibly should?
    taryn committed Jun 8, 2009
  2. Added update_attribute!

    just calls update_attribute and raises on failure
    taryn committed Jun 8, 2009
  3. Finally got a reasonably-working split_options.

    A lot of mucking-about to get to this point. Most of the previous checkins
    are non-working to some extent.
    The issue began with nested URLs when you pass through the nested id as a
    condition eg for a class Wdiegt with a nested URL such as:
    Widget.find(:first, :conditions => {:user_id => 42})
    would create a URL:
    which would break due to a lack of :user_id... even though it's present in
    the conditions.
    So I had to update the split_options method to search the conditions-string
    for possible prefix_parameters.
    Then it was passing it in both eg:
    Which is a bit icky doing double-filtering and sometimes broke the remote
    API stuff, so I updated split_options to remove any query_options that were
    already present in the prefix_options.
    For some reason one of these changes started introducing a whole bunch of
    null options - because the prefix_options start out with empty values (eg
    :select => nil), so I had to remove any keys that had a null value...
    but that broke the load method which opulls out attributes... which have
    null values that are meaningful... so I had to create a new option that can
    be passed in which allows me to keep null values if thay are meaningful.
    Exceptions to exceptions... :P
    But it now seems to cover all bases and not break previously-working code...
    taryn committed Jun 8, 2009