Class: EbayRequest::Config
- Inherits:
-
Object
- Object
- EbayRequest::Config
- Defined in:
- lib/ebay_request/config.rb
Instance Attribute Summary collapse
-
#appid ⇒ Object
Returns the value of attribute appid.
-
#certid ⇒ Object
Returns the value of attribute certid.
-
#devid ⇒ Object
Returns the value of attribute devid.
-
#runame ⇒ Object
Returns the value of attribute runame.
-
#sandbox ⇒ Object
(also: #sandbox?)
Returns the value of attribute sandbox.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .globalid_from_site_id(site_id) ⇒ Object
- .site_id_from_globalid(globalid) ⇒ Object
- .site_id_from_name(name) ⇒ Object
- .sites ⇒ Object
- .sites_by_globalid ⇒ Object
- .sites_by_id ⇒ Object
- .sites_by_name ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Config
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
#appid ⇒ Object
Returns the value of attribute appid.
3 4 5 |
# File 'lib/ebay_request/config.rb', line 3 def appid @appid end |
#certid ⇒ Object
Returns the value of attribute certid.
4 5 6 |
# File 'lib/ebay_request/config.rb', line 4 def certid @certid end |
#devid ⇒ Object
Returns the value of attribute devid.
5 6 7 |
# File 'lib/ebay_request/config.rb', line 5 def devid @devid end |
#runame ⇒ Object
Returns the value of attribute runame.
6 7 8 |
# File 'lib/ebay_request/config.rb', line 6 def runame @runame end |
#sandbox ⇒ Object 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 |
#timeout ⇒ Object
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/ebay_request/config.rb', line 10 def timeout @timeout end |
#version ⇒ Object
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 |
.sites ⇒ Object
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_globalid ⇒ Object
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_id ⇒ Object
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_name ⇒ Object
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 |