Sha256: d7cabda64484b5aba6bb0954ecb94ebe09c184257193bf43460b20dbe751ebe8

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

module Yogo
  module ExtensionModule
    def extended(base)
      case(base)
      when Class, Module
        base.class_eval(&class_extensions)
      else
        base.instance_eval(&instance_extensions)
      end
    end
    
    def included(base)
      extended(base)
    end
    
    def instance_extensions(&block)
      @_instance_extensions ||= lambda {}
      if block_given?
        @_instance_extensions = block
      end
      @_instance_extensions
    end
    
    def class_extensions(&block)
      @_class_extensions ||= lambda {}
      if block_given?
        @_class_extensions = block
      end
      @_class_extensions
    end
  end # ExtensionModule
end # Yogo

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yogo-support-0.1.1 lib/yogo/support/extension_module.rb
yogo-support-0.1.0 lib/yogo/support/extension_module.rb