Sha256: abfa7600cd9c3a631d91f0a87c26fac5f791112d0b65c1567f6934e1cca5a100

Contents?: true

Size: 347 Bytes

Versions: 26

Compression:

Stored size: 347 Bytes

Contents

class LazyModule < Module
  def self.new(&blk)
    # passing no-op block overrides &blk
    m = super{ }
    class << m
      include ClassMethods
    end
    m.lazy_evaluated_body = blk
    m
  end

  module ClassMethods
    attr_accessor :lazy_evaluated_body
    def included(host)
      host.class_eval(&@lazy_evaluated_body)
    end
  end
end

Version data entries

26 entries across 25 versions & 6 rubygems

Version Path
extlib-0.9.16 lib/extlib/lazy_module.rb
extlib-0.9.15 lib/extlib/lazy_module.rb
robsharp-extlib-0.9.15 lib/extlib/lazy_module.rb
sundbp-extlib-0.9.14 lib/extlib/lazy_module.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/extlib-0.9.14/lib/extlib/lazy_module.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/extlib-0.9.14/lib/extlib/lazy_module.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/extlib-0.9.14/lib/extlib/lazy_module.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/extlib-0.9.14/lib/extlib/lazy_module.rb
extlib-0.9.14 lib/extlib/lazy_module.rb
ginst-2009.12.8 vendor/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
ginst-2009.11.24 vendor/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
ginst-2009.11.23 vendor/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
rango-0.0.6 vendor/extlib/lib/extlib/lazy_module.rb
rango-0.1.pre vendor/extlib/lib/extlib/lazy_module.rb
middleman-0.10.17 vendor/gems/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
middleman-0.10.16 vendor/gems/gems/extlib-0.9.13/lib/extlib/lazy_module.rb
middleman-0.10.15 vendor/gems/gems/extlib-0.9.13/lib/extlib/lazy_module.rb