Class: FiberRecycling::RecycledFiberPoolBorrower

Inherits:
Object
  • Object
show all
Defined in:
lib/fiber_recycling/recycled_fiber_pool_borrower.rb

Instance Method Summary collapse

Constructor Details

#initialize(pool) ⇒ RecycledFiberPoolBorrower

Returns a new instance of RecycledFiberPoolBorrower.



4
5
6
7
# File 'lib/fiber_recycling/recycled_fiber_pool_borrower.rb', line 4

def initialize(pool)
  @pool = pool
  @recycled_fiber = nil
end

Instance Method Details

#retrieveObject



9
10
11
12
# File 'lib/fiber_recycling/recycled_fiber_pool_borrower.rb', line 9

def retrieve
  @recycled_fiber ||= @pool.release_recycled_fiber
  @recycled_fiber
end

#returnObject



14
15
16
17
# File 'lib/fiber_recycling/recycled_fiber_pool_borrower.rb', line 14

def return
  @pool.absorb_recycled_fiber(@recycled_fiber) if @recycled_fiber
  nil
end

#returned?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fiber_recycling/recycled_fiber_pool_borrower.rb', line 19

def returned?
  @recycled_fiber
end