Module: NomNom::Service

Defined in:
lib/nom_nom/service.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



10
11
12
# File 'lib/nom_nom/service.rb', line 10

def auth
  @auth
end

#moduleObject (readonly)

Returns the value of attribute module.



10
11
12
# File 'lib/nom_nom/service.rb', line 10

def module
  @module
end

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
# File 'lib/nom_nom/service.rb', line 3

def self.included(base)
  base.class_eval do
    include HTTParty
    extend ClassMethods
  end
end

Instance Method Details

#get(path, options = Hash.new) ⇒ Object



18
19
20
# File 'lib/nom_nom/service.rb', line 18

def get(path, options = Hash.new)
  self.class.get(path, { :basic_auth => @auth }.merge(options))
end

#initialize(uri, user, pass, mod = self.class.name) ⇒ Object



12
13
14
15
16
# File 'lib/nom_nom/service.rb', line 12

def initialize(uri, user, pass, mod = self.class.name)
  self.class.base_uri uri
  @auth = { :username => user, :password => pass } if user
  @module = mod.to_s.camelize
end