Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Commits on Aug 23, 2010
  1. @qoyyim-at-kiranatama

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

    qoyyim-at-kiranatama authored
    add :put and :delete params in find options
    edit readme
Commits on Aug 20, 2010
Commits on Jan 14, 2010
  1. Add before/after create callbacks

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

    taryneast authored
    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
    null-object.
    
    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!) :)
  2. Update to the raw_data to ensure format is reset back.

    taryneast authored
    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.
Commits on Sep 18, 2009
  1. Bugfix: arrayify, not arrayify!

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

    taryneast authored
    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.
Commits on Sep 2, 2009
  1. Update to README

    taryneast authored
    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
  2. Removal of an unsued line == cruft!

    taryn authored
  3. Add the sadly-overlooked has_one method

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

    taryn authored
    These should be in Rails core extensions...
  2. Added some defaults and sanity checks to split_options

    taryn authored
    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
Commits on Jun 19, 2009
  1. Bugfix: initialize not instantiate!

    taryn authored
    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"...
  2. raw_data lets us at the raw response without decoding.

    taryn authored
    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.
Commits on Jun 17, 2009
  1. Hack to fix primary_key for non-integer primary keys.

    taryn authored
    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!
Commits on Jun 16, 2009
  1. to_params-ification done so primary_key = :uuid should work now

    taryn authored
    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...
  2. Prettify with arrayify.

    taryn authored
  3. Big change - encode (eg create/update) only sends attributes we know …

    taryn authored
    …about
    
    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
    confused.
    
    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).
Commits on Jun 12, 2009
  1. Some bugfixes to get the dynamic creator working nicely.

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

    taryn authored
  3. Update Dynamic finders to ActiveRecord style and add instantiators

    taryn authored
    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
    arguments:
    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
  4. Updated README in line with current features.

    taryn authored
    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.
Commits on Jun 11, 2009
  1. Nested params can be taken from attributes.

    taryn authored
    As an attribute for a nested path is passed in - we should save it into the
    prefix_options.
    This allows us to do:
    
    thing = Thing.new(params[:thing])
    thing.user_id = current_user.id
    thing.save!
    
    or even
    
    thing = Thing.new(params[:thing])
    thing.user = current_user
    thing.save!
  2. Bugfixes for count-updates.

    taryn authored
    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
  3. Added description of count and your API

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

    taryn authored
    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.
  5. Bugfix to from_xml when an instance passed instead of xml

    taryn authored
    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
    associations.
    
    Also - a record should be able to instantiate from an instance of itself by
    duplicating!
Commits on Jun 8, 2009
  1. Add from_xml that instantiates the records in the xml.

    taryn authored
    "decode" doesn't appear to do that - it possibly should?
  2. Added update_attribute!

    taryn authored
    just calls update_attribute and raises on failure
  3. Finally got a reasonably-working split_options.

    taryn authored
    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:
    /users/:user_id/widgets
    Calling:
    Widget.find(:first, :conditions => {:user_id => 42})
    would create a URL:
    /users//widgets?conditions[user_id]=42
    
    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:
    
    /users/42/widgets?conditions[user_id]=42
    
    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...
Something went wrong with that request. Please try again.