Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6584

Show
Ignore:
Timestamp:
04/26/07 01:53:01 (1 year ago)
Author:
david
Message:

Added support for calling custom methods #6979 [rwdaigle]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activeresource/CHANGELOG

    r6569 r6584  
    11*SVN* 
     2 
     3* Added support for calling custom methods #6979 [rwdaigle] 
     4 
     5    Person.find(:managers)    # => GET /people/managers.xml 
     6    Kase.find(1).post(:close) # => POST /kases/1/close.xml 
    27 
    38* Remove explicit prefix_options parameter for ActiveResource::Base#initialize. [Rick] 
  • trunk/activeresource/lib/active_resource.rb

    r6119 r6584  
    3838require 'active_resource/struct' 
    3939require 'active_resource/validations' 
     40require 'active_resource/custom_methods' 
    4041 
    4142module ActiveResource 
    4243  Base.class_eval do 
    4344    include Validations 
     45    include CustomMethods 
    4446  end 
    4547end 
  • trunk/activeresource/lib/active_resource/base.rb

    r6570 r6584  
    123123          when :all   then find_every(options) 
    124124          when :first then find_every(options).first 
     125          when Symbol then get(scope, options) 
    125126          else             find_single(scope, options) 
    126127        end 
  • trunk/activeresource/lib/active_resource/http_mock.rb

    r6539 r6584  
    111111      headers[key] = value 
    112112    end 
     113     
     114    def ==(other) 
     115      if (other.is_a?(Response)) 
     116        other.body == body && other.message == message && other.headers == headers 
     117      else 
     118        false 
     119      end 
     120    end 
    113121  end 
    114122 
  • trunk/activeresource/test/base_test.rb

    r6568 r6584  
    9696 
    9797    assert_equal '/people.xml?gender=male', Person.collection_path('gender' => 'male') 
    98     assert_equal '/people.xml?gender=male&student=true', Person.collection_path(:gender => 'male', :student => true) 
     98     
     99    # Use includes? because ordering of param hash is not guaranteed 
     100    assert Person.collection_path(:gender => 'male', :student => true).include?('/people.xml?') 
     101    assert Person.collection_path(:gender => 'male', :student => true).include?('gender=male') 
     102    assert Person.collection_path(:gender => 'male', :student => true).include?('student=true') 
    99103 
    100104    assert_equal '/people.xml?name%5B%5D=bob&name%5B%5D=your+uncle%2Bme&name%5B%5D=&name%5B%5D=false', Person.collection_path(:name => ['bob', 'your uncle+me', nil, false])