class MethodLog::Scope
Attributes
parent[R]
Public Class Methods
new(name, parent = nil, singleton = false)
click to toggle source
# File lib/method_log/scope.rb, line 29 def initialize(name, parent = nil, singleton = false) @name = name @parent = parent @singleton = singleton @modules = {} end
Public Instance Methods
define(name)
click to toggle source
# File lib/method_log/scope.rb, line 48 def define(name) @modules[name] = Scope.new(name, parent = self) end
for(modules)
click to toggle source
# File lib/method_log/scope.rb, line 36 def for(modules) scope = self if modules.first == :root scope = root modules.unshift end modules.each do |mod| scope = scope.lookup(mod) || scope.define(mod) end scope end
lookup(name)
click to toggle source
# File lib/method_log/scope.rb, line 52 def lookup(name) @modules.fetch(name) { @parent.lookup(name) } end
method_identifier(name)
click to toggle source
# File lib/method_log/scope.rb, line 60 def method_identifier(name) [names.join('::'), separator, name].join end
root()
click to toggle source
# File lib/method_log/scope.rb, line 64 def root parent.root end
singleton()
click to toggle source
# File lib/method_log/scope.rb, line 56 def singleton Scope.new(@name, parent = self, singleton = true) end
Protected Instance Methods
names()
click to toggle source
# File lib/method_log/scope.rb, line 70 def names names = @singleton ? [] : [@name] names = @parent.names + names end
Private Instance Methods
separator()
click to toggle source
# File lib/method_log/scope.rb, line 77 def separator @singleton ? '.' : '#' end