Sha256: e2c620fafd7c78b6f77c475ca4459a2fd09887abcde6a0970699ad6c66b7542c

Contents?: true

Size: 668 Bytes

Versions: 5

Compression:

Stored size: 668 Bytes

Contents

# Delegates all missing methods to object specified by <tt>#delegate</tt> method.
module Delegated
  alias_method :old_method_missing, :method_missing
  alias_method :old_respond_to?, :respond_to?

  def method_missing(meth, *args, &block) # :nodoc:
    if (old_respond_to?(:delegate) && delegate.respond_to?(meth))
      delegate.send(meth, *args, &block)
    else
      old_method_missing(meth, *args, &block)
    end
  end

  def respond_to?(meth) # :nodoc:
    if (old_respond_to?(:delegate))
      delegate.respond_to?(meth) or old_respond_to?(meth)
    else
      old_respond_to?(meth)
    end
  end

  def to_s # :nodoc:
    delegate.to_s
  end
end # Delegated

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mustang-0.2.2 lib/mustang/support/delegated.rb
mustang-0.2.1 lib/mustang/support/delegated.rb
mustang-0.2.0 lib/mustang/support/delegated.rb
mustang-0.1.1 lib/support/delegated.rb
mustang-0.1.0 lib/support/delegated.rb