Module: Plumbum::Providers::Lazy
- Defined in:
- lib/plumbum/providers/lazy.rb
Overview
Provider that calls proc values and returns the result.
Add Plumbum::Providers::Lazy for values that have a consistent definition but changing value, such as class definitions under code reloading.
Instance Method Summary collapse
-
#get(key) ⇒ Object?
Retrieves the provided value for the given key.
Instance Method Details
#get(key) ⇒ Object?
Retrieves the provided value for the given key.
If the value is a Proc, the Proc is called and the value returned by the Proc is returned by #get. Otherwise, #get returns the value directly.
20 21 22 23 24 |
# File 'lib/plumbum/providers/lazy.rb', line 20 def get(key) value = super value.is_a?(Proc) ? value.call : value end |