Class: Class

Inherits:
Object show all
Defined in:
merb-core/lib/merb-core/core_ext/class.rb

Instance Method Summary (collapse)

Instance Method Details

- (Module) chainable(&blk)

Allows the definition of methods on a class that will be available via super.

Examples:

class Foo
  chainable do
    def hello
      "hello"
    end
  end
end

class Foo
  def hello
    super + " Merb!"
  end
end

Foo.new.hello #=> "hello Merb!"

Parameters:

  • &blk

    A block containing method definitions that should be marked as chainable

Returns:

  • (Module)

    The anonymous module that was created.



26
27
28
29
30
# File 'merb-core/lib/merb-core/core_ext/class.rb', line 26

def chainable(&blk)
  mod = Module.new(&blk)
  include mod
  mod
end