Sha256: b4c4c99f608dd07063456a3db4b62009103882b225ad12c938df1b08ec0c76a4
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
module DuckPuncher module Ducks module Object def clone! Marshal.load Marshal.dump self end unless defined? clone! def require!(file_or_gem, version = '') if DuckPuncher::GemInstaller.new.perform(file_or_gem, version) require file_or_gem.tr('-', '/') end end # @description Returns a new decorated version of ourself with the punches mixed in (adds ancestors decorators) # @return [<self.class>Delegator] def punch DuckPuncher.decorate self, DuckPuncher.undecorate(self).class end # @description Adds the duck punches to the current object (meant to be used on instances, careful with nil and numbers!) # @return self def punch! target = DuckPuncher.undecorate(self).class DuckPuncher::Ducks.load_mods(target).each { |mod| self.extend mod } self end def echo p "#{self} -- #{caller_locations[respond_to?(:__getobj__) ? 2 : 0]}" self end def track begin require 'object_tracker' || raise(LoadError) rescue LoadError DuckPuncher.(Object, only: :require!) unless respond_to? :require! require! 'object_tracker' end extend ::ObjectTracker track_all! end end end end
Version data entries
4 entries across 4 versions & 1 rubygems