Sha256: 6f4a865601f442ac62c1be8c90093bf8351fa91e5c1649df0c60e7d8657a9aab

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

Object.class_eval do
  undef :id if method_defined?(:id)
end

Array.class_eval do
  alias_method :index_without_block_form, :index
  def index(*args, &block)
    if args.empty? && block
      each_with_index { |obj, idx| return idx if block.call(obj) }; nil
    elsif args.size == 1
      index_without_block_form(*args, &block)
    else
      raise ArgumentError, "wrong number of arguments (%d for 1)" % args.size
    end
  end
end if Array.instance_method(:index).arity == 1

def URI(object)
  URI === object ? object : URI.parse(object.to_s)
end

URI.class_eval do
  def obfuscate
    returning(dup) do |obfuscated|
      obfuscated.user &&= '***'
      obfuscated.password &&= '***'
    end
  end
end

class << CGI
  alias_method :old_escape, :escape
  def escape(string)
    old_escape(string).gsub(/\./, '%' + '.'.unpack('H2')[0])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Roman2K-web-service-0.1.1 lib/web_service/core_ext.rb