Sha256: 72c1243131014b341e86a00ab2dd0ea495696891fd4b2095acfd3ac6bff336c8

Contents?: true

Size: 550 Bytes

Versions: 1

Compression:

Stored size: 550 Bytes

Contents

class ConcernedInheritance::Delegator < BasicObject

  attr_reader :baseclass, :subclass

  def initialize(baseclass, subclass, callback)
    @baseclass = baseclass
    @subclass  = subclass
    if callback.not_a?(::Proc)
      raise ::ArgumentError, "#{callback} must be a proc"
    elsif (-1..0).cover?(callback.arity)
      instance_eval(&callback)
    else
      raise ::ArgumentError, "#{callback} must have an arity of 0, got #{callback.arity}"
    end
  end

  def method_missing(m, *args, &block)
    subclass.send m, *args, &block
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
memory_model-0.0.1 lib/concerned_inheritance/delegator.rb