Class: Taskinator::Api::Processes
- Inherits:
-
Object
- Object
- Taskinator::Api::Processes
- Includes:
- Enumerable
- Defined in:
- lib/taskinator/api.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(scope = :shared) ⇒ Processes
constructor
A new instance of Processes.
- #size ⇒ Object
Constructor Details
#initialize(scope = :shared) ⇒ Processes
Returns a new instance of Processes.
8 9 10 11 |
# File 'lib/taskinator/api.rb', line 8 def initialize(scope=:shared) @scope = scope @processes_list_key = Taskinator::Persistence.processes_list_key(scope) end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/taskinator/api.rb', line 6 def scope @scope end |
Instance Method Details
#each(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/taskinator/api.rb', line 13 def each(&block) return to_enum(__method__) unless block_given? identifiers = Taskinator.redis do |conn| conn.smembers(@processes_list_key) end instance_cache = {} identifiers.each do |identifier| yield Process.fetch(identifier, instance_cache) end end |
#size ⇒ Object
26 27 28 29 30 |
# File 'lib/taskinator/api.rb', line 26 def size Taskinator.redis do |conn| conn.scard(@processes_list_key) end end |