Class: CanLII::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
lib/canlii/base.rb

Direct Known Subclasses

Case, Database

Class Method Summary collapse

Class Method Details

.with_client(client = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/canlii/base.rb', line 9

def with_client(client = nil)
  old_client = Thread.current[:canlii_client]

  if client
    Thread.current[:canlii_client] = client
    yield client
  else
    CanLII.configuration.validate!
    yield current_client
  end
ensure
  Thread.current[:canlii_client] = old_client
end