Sha256: b663655587cb7ba544193e40153d22b64ba06da4ed545bcee52ddbf5875638e7

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

# Block = BlockEnvironment

class Block {
  forwards_unary_ruby_methods
  metaclass forwards_unary_ruby_methods

  def receiver {
    """
    @return Receiver object of a @Block@.

    Returns the receiver of the @Block@ (value for @self)
    """
    @top_scope receiver
  }

  def receiver: recv {
    """
    @recv New receiver object for a @Block@.

    Sets the receiver (value for @self) of a @Block@.
    """
    @top_scope receiver: recv
  }

  # Ugh. HACK.
  # Use try/catch to deal with older and latest version of rbx (method got changed)
  def call_with_receiver: receiver {
    try {
      return call_under(receiver, method() scope())
    } catch {
      return call_on_instance(receiver)
    }
  }

  def call: args with_receiver: receiver {
    try {
      return call_under(receiver, method() scope(), *args)
    } catch {
      return call_on_instance(receiver, *args)
    }
  }

  def to_proc {
    """
    @return Ruby Proc representing @self.

    Turns a @Block@ into a Ruby Proc object.
    """

    Proc new(&self)
  }
}

class Rubinius VariableScope {
  forwards_unary_ruby_methods

  def receiver {
    @self
  }

  def receiver: recv {
    @self = recv
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fancy-0.4.0 lib/rbx/block.fy