Sha256: b46e024ecac0dc3c14c043ca32c87dead3302d7272c68ccdd1a106328cf3ed54

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

class ProxyReceiver : BasicObject {
  """
  A ProxyReceiver is an object which proxies all message sends to it to 2 other objects.
  It will send each message first to its @proxy instance variable and then to the @obj instance variable.
  """

  def initialize: @proxy for: @obj {
  }

  def unknown_message: msg with_params: params {
    @proxy send_message: msg with_params: params
    @obj send_message: msg with_params: params
  }
}

Proxy = ProxyReceiver

class RespondsToProxy : BasicObject {
  """
  A RespondsToProxy is a Proxy that forwards any message sent to it to it's @target instance variable
  only if it responds to that message. Any messages that @target doesn't respond to simply won't be sent
  and @nil will be returned.
  """

  def initialize: @target {
  }

  def unknown_message: msg with_params: params {
    if: (@target responds_to?: msg) then: {
      @target send_message: msg with_params: params
    }
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fancy-0.3.3 lib/proxy.fy