Class: BulkLoader::Lazy
- Inherits:
-
Object
- Object
- BulkLoader::Lazy
- Defined in:
- lib/bulk_loader/lazy.rb
Overview
lazy class
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #clear ⇒ Object
- #get ⇒ Object
-
#initialize(target, name: nil) ⇒ Lazy
constructor
A new instance of Lazy.
- #loaded? ⇒ Boolean
- #set(value) ⇒ Object
Constructor Details
#initialize(target, name: nil) ⇒ Lazy
Returns a new instance of Lazy.
10 11 12 13 14 15 |
# File 'lib/bulk_loader/lazy.rb', line 10 def initialize(target, name: nil) @loaded = false @value = nil @name = name @target = target end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/bulk_loader/lazy.rb', line 8 def target @target end |
Instance Method Details
#clear ⇒ Object
28 29 30 31 |
# File 'lib/bulk_loader/lazy.rb', line 28 def clear @loaded = false @value = nil end |
#get ⇒ Object
17 18 19 20 21 |
# File 'lib/bulk_loader/lazy.rb', line 17 def get raise UnloadAccessError, "#{@name} has not been loaded!!" unless @loaded @value end |
#loaded? ⇒ Boolean
33 34 35 |
# File 'lib/bulk_loader/lazy.rb', line 33 def loaded? @loaded end |
#set(value) ⇒ Object
23 24 25 26 |
# File 'lib/bulk_loader/lazy.rb', line 23 def set(value) @loaded = true @value = value end |