Class: Pharrell::Config::ObjectGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/pharrell/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &blk) ⇒ ObjectGenerator

Returns a new instance of ObjectGenerator.



39
40
41
42
# File 'lib/pharrell/config.rb', line 39

def initialize(options = {}, &blk)
  @blk = blk
  @options = options
end

Instance Method Details

#fetchObject



44
45
46
47
48
49
50
# File 'lib/pharrell/config.rb', line 44

def fetch
  if @options[:cache]
    @value ||= @blk.call
  else
    @blk.call
  end
end

#invalidate!Object



52
53
54
# File 'lib/pharrell/config.rb', line 52

def invalidate!
  @value = nil
end