Sha256: 8fd396380d2f629a57e1d250081e26a41a86740c6647e5272e9a4ef5af070855

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module Looksee
  module ObjectMixin
    #
    # Define #ls as a shortcut for Looksee[self, *args].
    #
    # This is defined via method_missing to be less intrusive. pry 0.10, e.g.,
    # relies on Object#ls not existing.
    #
    def method_missing(name, *args)
      if name == :ls
        Looksee[self, *args]
      else
        super
      end
    end

    def respond_to?(name, include_private=false)
      super || name == :ls
    end

    def self.rename(name)  # :nodoc:
      name = name[:ls] if name.is_a?(Hash)
      alias_method name, :ls
      remove_method :ls
    end
  end

  #
  # Rename the #ls method, added to every object. Example:
  #
  #     rename :_ls
  #
  # This renames Looksee's #ls method to #_ls.
  #
  # For backward compatibility, the old-style invocation is also
  # supported. Please note this is deprecated.
  #
  #     rename :ls => :_ls
  #
  def self.rename(name)
    ObjectMixin.rename(name)
  end

  name = ENV['LOOKSEE_METHOD'] and
    rename name

  Object.send :include, ObjectMixin
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
looksee-3.0.0-universal-java-1.8 lib/looksee/core_ext.rb
looksee-3.0.0 lib/looksee/core_ext.rb