Class: Reacto::Cache::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/reacto/cache/memory.rb

Instance Method Summary collapse

Constructor Details

#initialize(_ = nil) ⇒ Memory

Returns a new instance of Memory.



4
5
6
7
# File 'lib/reacto/cache/memory.rb', line 4

def initialize(_ = nil)
  @values = []
  @closed = false
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/reacto/cache/memory.rb', line 23

def closed?
  @closed
end

#eachObject



9
10
11
12
13
# File 'lib/reacto/cache/memory.rb', line 9

def each
  @values.each do |value|
    yield value
  end
end

#errorObject



27
28
29
# File 'lib/reacto/cache/memory.rb', line 27

def error
  @error
end

#error?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/reacto/cache/memory.rb', line 19

def error?
  @error != nil
end

#on_closeObject



39
40
41
# File 'lib/reacto/cache/memory.rb', line 39

def on_close
  @closed = true
end

#on_error(error) ⇒ Object



35
36
37
# File 'lib/reacto/cache/memory.rb', line 35

def on_error(error)
  @error = error
end

#on_value(value) ⇒ Object



31
32
33
# File 'lib/reacto/cache/memory.rb', line 31

def on_value(value)
  @values << value
end

#ready?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/reacto/cache/memory.rb', line 15

def ready?
  error? || closed?
end