Skip to content

Commit

Permalink
Explicitly define all of Registry's instance methods as singleton met…
Browse files Browse the repository at this point in the history
…hods delegated to instance.

Closes gh-26
  • Loading branch information
lsegal committed Aug 12, 2009
1 parent 78dafc2 commit 78eaa7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/yard/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ class Registry

class << self
attr_reader :objects

def method_missing(meth, *args, &block)
if instance.respond_to? meth
instance.send(meth, *args, &block)
else
super
end
end

def clear
instance.clear
Expand Down Expand Up @@ -141,6 +133,13 @@ def resolve(namespace, name, inheritance = false, proxy_fallback = false)
end
proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name) : nil
end

# Define all instance methods as singleton methods on instance
(public_instance_methods(false) - public_methods(false)).each do |meth|
module_eval(<<-eof, __FILE__, __LINE__ + 1)
def self.#{meth}(*args, &block) instance.send(:#{meth}, *args, &block) end
eof
end

private

Expand Down
1 change: 1 addition & 0 deletions spec/registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

describe YARD::Registry do
before { Registry.clear }

it "should have an empty path for root" do
Registry.root.path.should == ""
end
Expand Down

0 comments on commit 78eaa7a

Please sign in to comment.