Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added Pry::WrappedModule.from_str

  • Loading branch information...
commit df5931c681e7b6ced71ca22d263a040b30789ba3 1 parent 5a0f8ad
John Mair banister authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/pry/wrapped_module.rb
12 lib/pry/wrapped_module.rb
View
@@ -19,6 +19,18 @@ class WrappedModule
attr_reader :wrapped
private :wrapped
+ # Convert a string to a module.
+ #
+ # @param [String] mod_name
+ # @return [Module, nil] The module or `nil` (if conversion failed).
+ # @example
+ # Pry::WrappedModule.from_str("Pry::Code")
+ def self.from_str(mod_name)
+ Pry::WrappedModule.new(eval(mod_name))
+ rescue RescuableException
+ nil
+ end
+
# Create a new WrappedModule
# @raise ArgumentError, if the argument is not a Module
# @param [Module]
Please sign in to comment.
Something went wrong with that request. Please try again.