Class: Webspicy::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/webspicy/client.rb

Direct Known Subclasses

HttpClient, RackTestClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope) ⇒ Client



4
5
6
# File 'lib/webspicy/client.rb', line 4

def initialize(scope)
  @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



7
8
9
# File 'lib/webspicy/client.rb', line 7

def scope
  @scope
end

Instance Method Details

#after(*args, &bl) ⇒ Object



43
44
45
46
47
48
# File 'lib/webspicy/client.rb', line 43

def after(*args, &bl)
  args << self
  config.listeners(:after_each).each do |aeach|
    aeach.call(*args, &bl)
  end
end

#around(*args, &bl) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/webspicy/client.rb', line 13

def around(*args, &bl)
  args << self
  ls = config.listeners(:around_each)
  if ls.size == 0
    bl.call
  elsif ls.size > 1
    _around(ls.first, ls[1..-1], args, &bl)
  else
    ls.first.call(*args, &bl)
  end
end

#before(*args, &bl) ⇒ Object



36
37
38
39
40
41
# File 'lib/webspicy/client.rb', line 36

def before(*args, &bl)
  args << self
  config.listeners(:before_each).each do |beach|
    beach.call(*args, &bl)
  end
end

#configObject



9
10
11
# File 'lib/webspicy/client.rb', line 9

def config
  scope.config
end