Sha256: cba3e029c056e3d0620e79507e634496398b731cbea398983f761ee7b279cf7a
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
# encoding: utf-8 # from merb-core module Chainable # Allows the definition of methods on a class that will be available via # super. # # ==== Examples # class Foo # extend Chainable # chainable do # def hello # "hello" # end # end # end # # class Foo # def hello # super + " Merb!" # end # end # # # Example with mixin: # module TestMixin # extend Chainable # chainable do # def test # "from mixin!" # end # end # end # # class Test # include TestMixin # def test # "hello " + super # end # end # # puts Test.new.test # # # Foo.new.hello #=> "hello Merb!" # # ==== Parameters # &block:: # a block containing method definitions that should be # marked as chainable # # ==== Returns # Module:: The anonymous module that was created def chainable(method = nil, &block) if method.nil? && block_given? mixin = Module.new(&block) include mixin return mixin elsif method && ! block_given? # TODO # def test # # ... # end # chainable :test end end end
Version data entries
5 entries across 5 versions & 1 rubygems