Class: Rookout::Processor::Namespaces::FrameNamespace
- Defined in:
- lib/rookout/processor/namespaces/frame_namespace.rb
Instance Method Summary collapse
- #call_method(name, args) ⇒ Object
-
#initialize(frame_binding, top_frame_info) ⇒ FrameNamespace
constructor
A new instance of FrameNamespace.
- #locals(args) ⇒ Object
- #read_attribute(name) ⇒ Object
Methods inherited from Namespace
#dump, #read_key, #write_attribute
Constructor Details
#initialize(frame_binding, top_frame_info) ⇒ FrameNamespace
Returns a new instance of FrameNamespace.
10 11 12 13 14 |
# File 'lib/rookout/processor/namespaces/frame_namespace.rb', line 10 def initialize frame_binding, top_frame_info super() @frame_binding = frame_binding @top_frame_info = top_frame_info end |
Instance Method Details
#call_method(name, args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rookout/processor/namespaces/frame_namespace.rb', line 23 def call_method name, args case name when "filename", "module" RubyObjectNamespace.new @top_frame_info.path when "line" RubyObjectNamespace.new @top_frame_info.lineno when "function" RubyObjectNamespace.new @top_frame_info.label when "locals" locals args when "dump" result = { "filename" => RubyObjectNamespace.new(@top_frame_info.path), "line" => RubyObjectNamespace.new(@top_frame_info.lineno), "function" => RubyObjectNamespace.new(@top_frame_info.label), "module" => RubyObjectNamespace.new(@top_frame_info.path), "locals" => locals(args) } ContainerNamespace.new result else super end end |
#locals(args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rookout/processor/namespaces/frame_namespace.rb', line 47 def locals args raise Exceptions::RookLocalsUnavailable if @frame_binding.nil? dump_config = nil unless args.nil? dump_config = OBJECT_DUMP_TABLE[args.downcase] end hash = {} local_variables = @frame_binding.local_variables local_variables.each do |var| value = @frame_binding.local_variable_get var hash[var.to_s] = RubyObjectNamespace.new value, dump_config end hash["self"] = RubyObjectNamespace.new @frame_binding.receiver, dump_config ContainerNamespace.new hash end |
#read_attribute(name) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rookout/processor/namespaces/frame_namespace.rb', line 16 def read_attribute name raise Exceptions::RookLocalsUnavailable if @frame_binding.nil? return RubyObjectNamespace.new @frame_binding.receiver if name == "self" raise Exceptions::RookAttributeNotFound, name unless @frame_binding.local_variable_defined? name RubyObjectNamespace.new @frame_binding.local_variable_get name end |