Class: Ucenter::Interface::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ucenter/interface/base.rb

Overview

The Base class of API

Direct Known Subclasses

Authcode, User, Utility

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/ucenter/interface/base.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#db_clientObject



17
18
19
20
21
22
23
24
25
# File 'lib/ucenter/interface/base.rb', line 17

def db_client
  config = Hash.new
  config[:host]     = Ucenter::Config.uc_dbhost unless Ucenter::Config.uc_dbhost.nil?
  config[:username] = Ucenter::Config.uc_dbuser unless Ucenter::Config.uc_dbuser.nil?
  config[:password] = Ucenter::Config.uc_dbpw unless Ucenter::Config.uc_dbpw.nil?
  config[:database] = Ucenter::Config.uc_dbname unless Ucenter::Config.uc_dbname.nil?
  config[:encoding] = Ucenter::Config.uc_dbcharset unless Ucenter::Config.uc_dbcharset.nil?
  Mysql2::Client.new(config)
end

#get(path, opts = {}, &block) ⇒ Object



9
10
11
# File 'lib/ucenter/interface/base.rb', line 9

def get(path, opts={}, &block)
  request(:get, path, opts, &block)
end

#post(path, opts = {}, &block) ⇒ Object



13
14
15
# File 'lib/ucenter/interface/base.rb', line 13

def post(path, opts={}, &block)
  request(:post, path, opts, &block)
end