Sha256: 03117de45b405058efac841f9e1b29257c39be1787b9def5ca7525f486f69d15

Contents?: true

Size: 874 Bytes

Versions: 19

Compression:

Stored size: 874 Bytes

Contents

module Kernel  
  def silently(&blk)
    old_verbose, $VERBOSE = $VERBOSE, nil
    yield
    $VERBOSE = old_verbose
  end   
end

class Module  
  def undef_methods(*methods)
    methods.each { |name| undef_method(name) }
  end
end

class Object
  def to_jail
    Safemode.jail self
  end
end

# As every call to an object in the eval'ed string will be jailed by the
# parser we don't need to "proactively" jail arrays and hashes. Likewise we
# don't need to jail objects returned from a jail. Doing so would provide
# "double" protection, but it also would break using a return value in an if
# statement, passing them to a Rails helper etc.

# class Array
#   def to_jail
#     Safemode.jail collect{ |obj| obj.to_jail }
#   end
# end
# 
# class Hash
#   def to_jail
#     hash = {}
#     collect{ |key, obj| hash[key] = obj.to_jail}
#     Safemode.jail hash
#   end
# end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
safemode-1.3.8 lib/safemode/core_ext.rb
safemode-1.3.7 lib/safemode/core_ext.rb
safemode-1.3.6 lib/safemode/core_ext.rb
safemode-1.3.5 lib/safemode/core_ext.rb
safemode-1.3.4 lib/safemode/core_ext.rb
safemode-1.3.3 lib/safemode/core_ext.rb
safemode-1.3.2 lib/safemode/core_ext.rb
safemode-1.3.1 lib/safemode/core_ext.rb
safemode-1.2.5 lib/safemode/core_ext.rb
safemode-1.2.4 lib/safemode/core_ext.rb
safemode-1.2.3 lib/safemode/core_ext.rb
safemode-1.2.2 lib/safemode/core_ext.rb
safemode-1.2.1 lib/safemode/core_ext.rb
safemode-1.0.2 lib/safemode/core_ext.rb
safemode-1.2.0 lib/safemode/core_ext.rb
safemode-1.1.0 lib/safemode/core_ext.rb
safemode-1.0.1 lib/safemode/core_ext.rb
safemode-1.0.0 lib/safemode/core_ext.rb
safemode-0.0.2 lib/safemode/core_ext.rb