Class: Eventually::Callable

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/eventually/callable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callable, block, availability = :continuous) ⇒ Callable

Returns a new instance of Callable.



12
13
14
15
# File 'lib/eventually/callable.rb', line 12

def initialize(callable, block, availability=:continuous)
  @callable = pick_callable(callable, block)
  @availability = availability
end

Instance Attribute Details

#availabilityObject

Returns the value of attribute availability.



8
9
10
# File 'lib/eventually/callable.rb', line 8

def availability
  @availability
end

#callableObject (readonly)

Returns the value of attribute callable.



7
8
9
# File 'lib/eventually/callable.rb', line 7

def callable
  @callable
end

Instance Method Details

#continuous?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/eventually/callable.rb', line 28

def continuous?
  @availability == :continuous
end

#pick_callable(c, b) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/eventually/callable.rb', line 17

def pick_callable(c, b)
  cb = nil
  if c.respond_to?(:call)
    cb = c
  elsif !b.nil?
    cb = b
  else
    raise 'Cannot register callable. Neither callable nor block was given.'
  end
end