Sha256: 8bcfddd2656d80e5df24677231621555c921c250634f2c461715c44807223e2c

Contents?: true

Size: 469 Bytes

Versions: 4

Compression:

Stored size: 469 Bytes

Contents

# frozen_string_literal: true

module BulkLoader
  # lazy class
  class Lazy
    attr_reader :target

    def initialize(target)
      @loaded = false
      @value = nil
      @target = target
    end

    def get
      raise 'data is not loaded!!' unless @loaded

      @value
    end

    def set(value)
      @loaded = true
      @value = value
    end

    def clear
      @loaded = false
      @value = nil
    end

    def loaded?
      @loaded
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bulk_loader-1.1.0 lib/bulk_loader/lazy.rb
bulk_loader-1.0.0 lib/bulk_loader/lazy.rb
bulk_loader-0.4.0 lib/bulk_loader/lazy.rb
bulk_loader-0.3.0 lib/bulk_loader/lazy.rb