Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Updated ManyToOne::Proxy to delegate #class to parent
Browse files Browse the repository at this point in the history
* Fixes issue with Merb resource() helper method not being able to
  figure out route using ManyToOne::Proxy object.

[#628 state:resolved]
  • Loading branch information
Dan Kubb committed Nov 30, 2008
1 parent d52ade5 commit 63c50c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/dm-core/associations/many_to_one.rb
Expand Up @@ -48,7 +48,7 @@ def #{name}_association
class Proxy
include Assertions

instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m) }
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }

def replace(parent)
@parent = parent
Expand Down
2 changes: 1 addition & 1 deletion lib/dm-core/associations/one_to_many.rb
Expand Up @@ -72,7 +72,7 @@ def #{name}_association
class Proxy
include Assertions

instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m) }
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }

# FIXME: remove when RelationshipChain#get_children can return a Collection
def all(query = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/dm-core/query.rb
Expand Up @@ -573,7 +573,7 @@ def initialize(target, operator)
class Path
include Assertions

%w[ id type ].each { |m| undef_method m }
instance_methods.each { |m| undef_method m if %w[ id type ].include?(m.to_s) }

attr_reader :relationships, :model, :property, :operator

Expand Down
7 changes: 7 additions & 0 deletions spec/unit/associations/many_to_one_spec.rb
Expand Up @@ -30,6 +30,13 @@ class Vehicle
@association.should respond_to(:replace)
end

describe '#class' do
it 'should be forwarded to parent' do
@parent.should_receive(:class).and_return(Manufacturer)
@association.class.should == Manufacturer
end
end

describe '#replace' do
before do
@other = mock('other parent')
Expand Down

0 comments on commit 63c50c4

Please sign in to comment.