Module: OpenSource::Public

Defined in:
lib/open_source.rb

Instance Method Summary collapse

Instance Method Details

#open_source(obj) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/open_source.rb', line 12

def open_source(obj)
  case obj.class
  when Class, Module
    case obj
    when String
      begin
        Utils.handle_constant! Object.const_get obj
      rescue NameError
        Utils.handle_method_or_name! obj
      end
    when Symbol
      Utils.handle_method_or_name! obj
    when Method, UnboundMethod
      Utils.handle_method_or_name! obj
    else
      Utils.handle_constant! obj
    end
  else
    raise UnopenableError, "Cannot open #{obj.inspect} (#{obj.class}) in an editor"
  end
end