Sha256: 46aa4b5079d0e3303991c8951e8eb6d6c79edebb0c2c9495a32a1401a877a560

Contents?: true

Size: 879 Bytes

Versions: 18

Compression:

Stored size: 879 Bytes

Contents

require "delegate"

class Restly::Proxies::Base < SimpleDelegator

  delegate :is_a?, :kind_of?, to: :__getobj__

  # Initialize the Proxy
  def initialize(receiver)

    # Dupe the Requester
    if receiver.class == Class

      @receiver = receiver.dup

      # Some Key Methods Added to the Duplicated Requester
      @receiver.class_eval %{

        def inspect
          super.gsub(/^(#<)?#<[a-z0-9]+:([a-z0-9]+)(>)?/i, '#<#{receiver.name}:\\2')
        end

        def self.inspect
          super.gsub(/^#<[a-z0-9]+:.*/i, '#{receiver.name}')
        end

        def self.name
          "#{receiver.name}"
        end

      }
    else
      @receiver = receiver
    end

    # Initialize the Delegator
    super(@receiver)
  end

  alias_method :proxy_class, :class

  # Tell the Proxy its Class!
  def class
    @receiver.class
  end

  def proxied?
    true
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
restly-0.0.1.beta.10 lib/restly/proxies/base.rb
restly-0.0.1.beta.9 lib/restly/proxies/base.rb
restly-0.0.1.beta.6 lib/restly/proxies/base.rb
restly-0.0.1.beta.5 lib/restly/proxies/base.rb
restly-0.0.1.beta.4 lib/restly/proxies/base.rb
restly-0.0.1.beta.3 lib/restly/proxies/base.rb
restly-0.0.1.beta.2 lib/restly/proxies/base.rb
restly-0.0.1.beta.1 lib/restly/proxies/base.rb
restly-0.0.1.alpha.22 lib/restly/proxies/base.rb
restly-0.0.1.alpha.19 lib/restly/proxies/base.rb
restly-0.0.1.alpha.18 lib/restly/proxies/base.rb
restly-0.0.1.alpha.16 lib/restly/proxies/base.rb
restly-0.0.1.alpha.12 lib/restly/proxies/base.rb
restly-0.0.1.alpha.11 lib/restly/proxies/base.rb
restly-0.0.1.alpha.10 lib/restly/proxies/base.rb
restly-0.0.1.alpha.9 lib/restly/proxies/base.rb
restly-0.0.1.alpha.8 lib/restly/proxies/base.rb
restly-0.0.1.alpha.7 lib/restly/proxies/base.rb