Sha256: 2534a3a2d003abbd462f89d54a397367467b910f0e3dbc898ee33df7998a0094

Contents?: true

Size: 671 Bytes

Versions: 5

Compression:

Stored size: 671 Bytes

Contents

class Object

  def self.run_once(unique_string, &block)
    $run_once_guard ||= {}
    return if $run_once_guard[unique_string]
    raise "No block given" unless block_given?
    yield
    $run_once_guard[unique_string] = true
  end
  
  def to_class
    self.class.const_get self.to_s
  end
  
  def in?(array)
    array.include? self
  end

	# based on http://www.rubygarden.org/ruby?Make_A_Deep_Copy_Of_An_Object
	def deep_clone
		Marshal::load(Marshal.dump(self))
	end

	def ignore_exception(*exceptions, &block)
		begin
			yield
		rescue Exception => e
			skip = false
			exceptions.each { |ex| skip = true if e.kind_of? ex }
			raise e unless skip
		end
	end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
smklib-1.2.0 lib/smklib/object_ext.rb
smklib-1.1.2 lib/smklib/object_ext.rb
smklib-1.1.1 lib/smklib/object_ext.rb
smklib-1.1.0 lib/smklib/object_ext.rb
smklib-1.0.6 lib/smklib/object_ext.rb