Skip to content
This repository

Jan 12, 2014

  1. Rémi Prévost

    Merge pull request #198 from vic/new_can_take_existing_objects

    New can take existing objects
    authored January 12, 2014
  2. Rémi Prévost

    Merge pull request #199 from vic/association_value

    Forward *almost* all methods to the fetched object.
    authored January 12, 2014

Nov 10, 2013

  1. Victor Hugo Borja

    Use a blank-object proxy object for associations.

    Use an ActiveSuport::BlankObject so the value
    returned by the association method does not
    masks methods inherited from Object/Kernel and
    does actually forwards them to the fetched
    object.
    authored November 09, 2013
  2. Victor Hugo Borja

    Value of association method aint mask core methods

    It was somewhat weird that `her` association methods
    returned an object that in some cases masked some of
    the methods defined by Object / Kernel instead of
    delegating them to the fetched value.
    
    Suppose you had a relation where a `User` has one
    `Role`. After fetching the `user` object along with
    it's associated role, if you did called `class` on it
    
    ```ruby
      user.role.class # => Her::Associations::HasOneAssociation
    ```
    
    returned the association class instead of the most
    likely expected `Role` class. This happened with
    almost any method defined on Object, for example:
    
    ```ruby
      module M
        def m
          1
        end
      end
    
      role = Role.new
      user = User.new
      user.role = role
    
      user.role.extend M
      user.role.m # => raised undefined method m
      role.kind_of?(M) # => should have been true
    ```
    
    In the previous example, extending the value
    returned by `user.role` was actually extending
    the `association` object instead of the actual
    role object.
    
    Some other unfortunate effects of the way it
    used to be was that calling `user.role.to_json`
    was trying to serialize the relation object
    along all it's metadata (params, parent, etc)
    instead of the role object.
    
    So I think that instead of having `her` users
    to think about explicitly doing `.fetch` for
    their code to work, why not making it work as
    they should actually expect from any other
    library like active record.
    
    The way I approached this was by making the
    association method to return a BlankObject
    (actually ActiveSupport::BlankObject) proxy
    that has *almost no method* defined, and
    thus it cannot mask methods you actually
    intended to call on the fetched object.
    So all methods on this proxy are forwarded
    to the fetched object, except for a handful
    of them like `where`, `find`, etc,
    which get called on the association.
    
    One important thing to notice is that I
    intentionally left out the `fetch` method
    from the methods defined on the proxy.
    But I added an `association` one which
    returns the association object upon which
    you can still call fetch, if you'd ever
    need to `user.role.association.fetch`.
    
    I consider the `fetch` method should not
    not be directly defined on the proxy as
    no one should actually need to manually
    call it (as you never do with activerecord
    to retrieve objects from the database).
    And if you do *need* to call `fetch`
    explicitely, then I guess you are in
    that case aware you're working with an
    non-active-record thingy but a `her` one.
    That's why you can still do `association.fetch`.
    
    So this have been a quite large commit
    message, but I hope it explains why
    I decided to spend a day fixing this
    on `her`, in the hope of avoiding others
    the hard times I got this week while
    finding these unpexected hevaviours.
    
    Besides all, thanks for making `her`
    it's such an awesome library.
    authored November 09, 2013
  3. Victor Hugo Borja

    Allow model constructors to take already initalized objects

    If a constructor argument is an already contructed object
    (that is, it's a kind_of of the associated class), simply
    use the given object as the association value.
    
    This allows `her` to behave a bit more as expected by
    normal rails guys.
    
    ```ruby
       User.new(organization: already_fetched_org)
    ```
    authored November 09, 2013
  4. Victor Hugo Borja

    fix example typo

    authored November 09, 2013

Nov 03, 2013

  1. Rémi Prévost

    Remove Coveralls, what

    authored November 03, 2013
  2. Rémi Prévost

    Add Coveralls

    authored November 03, 2013
  3. Rémi Prévost

    Merge pull request #167 from RevSpringPhoenix/master

    added support for legacy ruby version gem requirements
    authored November 03, 2013
  4. Rémi Prévost

    Merge pull request #188 from monterail/belongs-to-nested-models-fix-f…

    …or-missing-foreign-key
    
    Belongs to nested models fix for missing foreign key
    authored November 03, 2013
  5. Rémi Prévost

    Merge pull request #191 from vic/find_many_by_id_single_request

    Fetch many instances by id on a single request.
    authored November 03, 2013
  6. Rémi Prévost

    Merge pull request #192 from kenips/symbolize_hash_keys

    Allow middlewares to return hash with String keys.
    authored November 03, 2013
  7. Rémi Prévost

    Merge pull request #194 from agrobbin/parse-root-superclass-format

    Allow parse_root_in_json's format option to be inherited
    authored November 03, 2013

Nov 01, 2013

  1. Alex Robbin

    allow parse_root_in_json's format option to be inherited

    authored November 01, 2013
  2. Ken Ip

    Allow middlewares to return hash with String keys.

    authored November 01, 2013

Oct 30, 2013

  1. Victor Hugo Borja

    Fetch many instances by id on a single request.

    Some times you'd like to find many instances by id
    with a single request. Using `where(id: [1, 2])` is
    most likely the way rails people would try to do this.
    So I just fixed Her to treat `id` as yet another
    request param if its value turns out to be an array.
    authored October 29, 2013

Oct 23, 2013

  1. Tymon Tobolski

    Do not require foreign key for belongs_to nested models

    authored October 23, 2013
  2. Tymon Tobolski

    Failing spec

    authored August 20, 2013

Oct 21, 2013

  1. Rémi Prévost

    Merge pull request #182 from centro/master

    Set the ActiveModel::Dirty #changed_attributes and #previous_changes correctly.
    authored October 21, 2013
  2. Chris Lamb

    Show changes for a new record, but not an exiting one.

    authored October 21, 2013

Oct 18, 2013

  1. Rémi Prévost

    Add comment in middleware examples

    authored October 18, 2013
  2. Nils Caspar

    Merge pull request #184 from remiprev/fix-parse-spec

    Actually test the send_only_modified_attributes functionality
    authored October 18, 2013

Oct 16, 2013

  1. Nils Caspar

    Actually test the send_only_modified_attributes functionality

    authored October 16, 2013
  2. Rémi Prévost

    Remove travis tests for ruby-1.8.7

    authored October 15, 2013

Oct 15, 2013

  1. Rémi Prévost

    Merge pull request #183 from remiprev/fix/remove-custom-respond-to

    Remove redefined “respond_to?” method
    authored October 15, 2013
  2. Rémi Prévost

    Remove redefined “respond_to?” method

    authored October 15, 2013
  3. Rémi Prévost

    Remove duplicate condition in “or” clause

    authored October 15, 2013

Oct 14, 2013

  1. Chris Lamb

    Fix spec indentation.

    authored October 14, 2013
  2. Chris Lamb

    Always set @changed_attributes to {} after initializing.

    authored October 14, 2013
  3. Chris Lamb

    Set previously_changed attributes when #save is called.

    authored October 14, 2013
  4. Chris Lamb

    There are no changed_attributes for a #find.

    authored October 14, 2013

Sep 10, 2013

  1. Rémi Prévost

    Merge pull request #157 from alfonsocora/send_only_modified_attributes

    Add option to only send the modified attributes
    authored September 10, 2013

Aug 09, 2013

  1. Bruce White

    Update her.gemspec

    Add activemodel and activesupport dependency back
    authored August 09, 2013

Aug 07, 2013

  1. Michael Christenson II

    added support for legacy ruby version gem requirements

    authored August 07, 2013

Aug 06, 2013

  1. Rémi Prévost

    Merge pull request #166 from RevSpringPhoenix/master

    use_api accepts Procs
    authored August 06, 2013
Something went wrong with that request. Please try again.