Class: Pry

Inherits:
Object
  • Object
show all
Defined in:
lib/pry/hack.rb

Defined Under Namespace

Modules: Hackage

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_hack(type, handle, hack) ⇒ Pry::Hackage::Hack

Adds a hack to pry for use in the REPL.



42
43
44
45
# File 'lib/pry/hack.rb', line 42

def self.add_hack(type, handle, hack)
  (eval "self.config.hack.s.#{self.config.hack.implications.send(:method_missing, type)||type}")[handle] = hack
  return hack
end

.remove_hack(type, handle) ⇒ Fixnum

Removes a method from use in the REPL, added by add_hack



53
54
55
56
57
# File 'lib/pry/hack.rb', line 53

def self.remove_hack(type, handle)
  si = self.config.hack.collect(&:size).reduce(0,:+)
  self.config.hack.each {|hash| hash.delete(handle)}
  return si - self.config.hack.collect(&:size).reduce(0,:+)
end

Instance Method Details

#old_retrieve_lineObject



218
# File 'lib/pry/hack.rb', line 218

alias_method :old_retrieve_line, :retrieve_line

#retrieve_line(eval_string, *args) ⇒ Object



220
221
222
223
# File 'lib/pry/hack.rb', line 220

def retrieve_line(eval_string, *args)
  old_retrieve_line(eval_string, *args)
  puts eval_string.sub!(/^.+?$/, Hackage.hack_line(eval_string))
end