Class: Assonnato::Client

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/assonnato/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Request

#get, #post

Constructor Details

#initialize(host = 'pigro.omnivium.it', port = 80, ssl = false) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
# File 'lib/assonnato/client.rb', line 16

def initialize(host = 'pigro.omnivium.it', port = 80, ssl = false)
  @host    = host
  @port    = port
  @ssl     = ssl
  @cookies = CookieJar.new
end

Instance Attribute Details

#cookiesObject (readonly)

Returns the value of attribute cookies.



14
15
16
# File 'lib/assonnato/client.rb', line 14

def cookies
  @cookies
end

#hostObject

Returns the value of attribute host.



13
14
15
# File 'lib/assonnato/client.rb', line 13

def host
  @host
end

#portObject

Returns the value of attribute port.



13
14
15
# File 'lib/assonnato/client.rb', line 13

def port
  @port
end

Class Method Details

.namespace(*names) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/assonnato/client.rb', line 23

def self.namespace(*names)
  options = names.last.is_a?(Hash) ? names.pop : {}
  names   = names.map(&:to_sym)
  name    = names.pop
  return if public_method_defined?(name)

  converted  = options.fetch(:full_name, name).to_s
  converted  = converted.split('_').map(&:capitalize).join
  class_name = ''
  class_name = "#{self.name.split('::').last}::" unless options.fetch(:root, false)
  class_name += converted

  define_method(name) do
    ApiFactory.new class_name, self
  end

  self
end