Skip to content

Commit

Permalink
Minor: formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Nov 9, 2009
1 parent 18ef8b6 commit 4ca393e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
15 changes: 9 additions & 6 deletions lib/mongo_mapper/associations/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ def reload_target
end

def send(method, *args)
meths = class << self; self; end.instance_methods
stringified_method = method.to_s
return __send__(method, *args) if meths.any? { |meth| meth.to_s == stringified_method }
metaclass_instance_methods = class << self; self; end.instance_methods

if metaclass_instance_methods.any? { |m| m.to_s == method.to_s }
return __send__(method, *args)
end

load_target
@target.send(method, *args)
end
Expand All @@ -49,10 +52,10 @@ def nil?
protected
def method_missing(method, *args, &block)
if load_target
unless block.nil?
@target.send(method, *args) { |*block_args| block.call(*block_args) }
else
if block.nil?
@target.send(method, *args)
else
@target.send(method, *args) { |*block_args| block.call(*block_args) }
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/mongo_mapper/embedded_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ def from_mongo(instance_or_hash)

private
def accessors_module
module_defined = if method(:const_defined?).arity == 1
const_defined?('MongoMapperKeys')
else
const_defined?('MongoMapperKeys', false)
end
module_defined = if method(:const_defined?).arity == 1 # Ruby 1.9 compat check
const_defined?('MongoMapperKeys')
else
const_defined?('MongoMapperKeys', false)
end

if module_defined
const_get 'MongoMapperKeys'
Expand Down
7 changes: 3 additions & 4 deletions test/functional/test_pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ def self.per_page; 1 end
result.should == [@doc1, @doc3]
result.first.age.should == 27


result = @document.paginate({
:conditions => {:last_name => 'Nunemaker'},
:order => "age DESC",
:per_page => 2,
:page => 1} )
:order => "age DESC",
:per_page => 2,
:page => 1} )
result.should == [@doc1, @doc3]
result.first.age.should == 27
end
Expand Down

0 comments on commit 4ca393e

Please sign in to comment.