Class: EbayRequest::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ebay_request/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
# File 'lib/ebay_request/config.rb', line 14

def initialize
  @sandbox ||= true
  @version ||= 941
  @timeout ||= 60
end

Instance Attribute Details

#appidObject

Returns the value of attribute appid.



3
4
5
# File 'lib/ebay_request/config.rb', line 3

def appid
  @appid
end

#certidObject

Returns the value of attribute certid.



4
5
6
# File 'lib/ebay_request/config.rb', line 4

def certid
  @certid
end

#devidObject

Returns the value of attribute devid.



5
6
7
# File 'lib/ebay_request/config.rb', line 5

def devid
  @devid
end

#runameObject

Returns the value of attribute runame.



6
7
8
# File 'lib/ebay_request/config.rb', line 6

def runame
  @runame
end

#sandboxObject Also known as: sandbox?

Returns the value of attribute sandbox.



8
9
10
# File 'lib/ebay_request/config.rb', line 8

def sandbox
  @sandbox
end

#timeoutObject

Returns the value of attribute timeout.



10
11
12
# File 'lib/ebay_request/config.rb', line 10

def timeout
  @timeout
end

#versionObject

Returns the value of attribute version.



9
10
11
# File 'lib/ebay_request/config.rb', line 9

def version
  @version
end

Class Method Details

.globalid_from_site_id(site_id) ⇒ Object



28
29
30
# File 'lib/ebay_request/config.rb', line 28

def globalid_from_site_id(site_id)
  (site = sites_by_id[site_id]) && site.globalid
end

.site_id_from_globalid(globalid) ⇒ Object



32
33
34
# File 'lib/ebay_request/config.rb', line 32

def site_id_from_globalid(globalid)
  (site = sites_by_globalid[globalid.to_s.upcase]) && site.id
end

.site_id_from_name(name) ⇒ Object



36
37
38
# File 'lib/ebay_request/config.rb', line 36

def site_id_from_name(name)
  (site = sites_by_name[name]) && site.id
end

.sitesObject



40
41
42
43
44
45
# File 'lib/ebay_request/config.rb', line 40

def sites
  @sites ||=
    YAML.load_file(
      File.join(File.dirname(__FILE__), "../../config/sites.yml")
    ).map { |h| EbayRequest::Site.new h }
end

.sites_by_globalidObject



51
52
53
# File 'lib/ebay_request/config.rb', line 51

def sites_by_globalid
  @sites_by_globalid ||= Hash[sites.map { |s| [s.globalid, s] }]
end

.sites_by_idObject



47
48
49
# File 'lib/ebay_request/config.rb', line 47

def sites_by_id
  @sites_by_id ||= Hash[sites.map { |s| [s.id, s] }]
end

.sites_by_nameObject



55
56
57
# File 'lib/ebay_request/config.rb', line 55

def sites_by_name
  @sites_by_name ||= Hash[sites.map { |s| [s.name, s] }]
end

Instance Method Details

#validate!Object



20
21
22
23
24
25
# File 'lib/ebay_request/config.rb', line 20

def validate!
  %w(appid certid devid runame).each do |attr|
    value = public_send(attr)
    raise "Set EbayRequest.config.#{attr}" if value.nil? || value.empty?
  end
end