Class: YARD::StubProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/serializers/yardoc_serializer.rb

Overview

Stubs marshal dumps and acts a delegate class for an object by path

Constant Summary collapse

FILELEN =
__FILE__.size

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, transient = false) ⇒ StubProxy

Returns a new instance of StubProxy.



13
14
15
16
# File 'lib/yard/serializers/yardoc_serializer.rb', line 13

def initialize(path, transient = false)
  @path = path
  @transient = transient
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/yard/serializers/yardoc_serializer.rb', line 18

def method_missing(meth, *args, &block)
  return true if meth == :respond_to? && args.first == :_dump
  @object = nil if @transient
  @object ||= Registry.at(@path)
  @object.send(meth, *args, &block)
rescue NoMethodError => e
  e.backtrace.delete_if {|l| l[0, FILELEN] == __FILE__ }
  raise
end

Class Method Details

._load(str) ⇒ Object



10
# File 'lib/yard/serializers/yardoc_serializer.rb', line 10

def self._load(str) new(str) end

Instance Method Details

#_dump(_depth) ⇒ Object



9
# File 'lib/yard/serializers/yardoc_serializer.rb', line 9

def _dump(_depth) @path end

#hashObject



11
# File 'lib/yard/serializers/yardoc_serializer.rb', line 11

def hash; @path.hash end