Sha256: fa88adc56cf074533dafa46f4981696e6b3561dbb77f25eb9efe19aebff83d07

Contents?: true

Size: 586 Bytes

Versions: 4

Compression:

Stored size: 586 Bytes

Contents

module Subtle
  class LazyCover < Cover
    include Subtle::StrictCoverMethods

    def initialize(block)
      @block = block
    end

    alias :the_original_subject_from_the_base_class :the_original_subject
    def the_original_subject
      setup_the_subject
      the_original_subject_from_the_base_class
    end

    private

    alias :old_method_missing :method_missing
    def method_missing(meth, *args, &blk)
      setup_the_subject
      old_method_missing meth, *args, &blk
    end

    def setup_the_subject
      @subject = @block.call if @subject.nil?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
subtle-0.3.8 lib/subtle/lazy_cover.rb
subtle-0.3.6 lib/subtle/lazy_cover.rb
subtle-0.3.5 lib/subtle/lazy_cover.rb
subtle-0.3.4 lib/subtle/lazy_cover.rb