Class: Igniter::LedgerClient::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/ledger_client/subscription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&close_proc) ⇒ Subscription

Returns a new instance of Subscription.



8
9
10
11
12
# File 'lib/igniter/ledger_client/subscription.rb', line 8

def initialize(&close_proc)
  @close_proc = close_proc
  @closed = false
  @mutex = Mutex.new
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



6
7
8
# File 'lib/igniter/ledger_client/subscription.rb', line 6

def error
  @error
end

Instance Method Details

#closeObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/igniter/ledger_client/subscription.rb', line 14

def close
  close_proc = nil
  @mutex.synchronize do
    return self if @closed

    @closed = true
    close_proc = @close_proc
  end

  close_proc&.call
  self
end

#closed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/igniter/ledger_client/subscription.rb', line 27

def closed?
  @mutex.synchronize { @closed }
end