lib/ebay/config.rb in ebay-ruby-0.2.0 vs lib/ebay/config.rb in ebay-ruby-0.3.0

- old
+ new

@@ -1,15 +1,40 @@ +# frozen_string_literal: true + +# Ruby wrapper to the eBay APIs module Ebay + # Configures credentials for accessing the eBay APIs + # @yield {Config} + def self.configure + yield Config + end + + # Stores credentials for accessing the eBay APIs module Config class << self - %i(app_id dev_id cert_id).each do |method| - eval <<-DEF - attr_writer :#{method} + # @!attribute [rw] app_id + # @return [String] unique identifier for the application + # @note This attribute defaults to the `EBAY_APP_ID` environment variable. + def app_id + @app_id ||= ENV['EBAY_APP_ID'] + end - def #{method} - @#{method} || ENV['EBAY_#{method.upcase}'] - end - DEF + # @!attribute [rw] dev_id + # @return [String] unique identifier for the developer's account + # @note This attribute defaults to the `EBAY_DEV_ID` environment variable. + def dev_id + @dev_id ||= ENV['EBAY_DEV_ID'] end + + # @!attribute [rw] cert_id + # @return [String] certificate that authenticates the application when + # making API calls + # @note This attribute defaults to the `EBAY_CERT_ID` environment + # variable. + def cert_id + @cert_id ||= ENV['EBAY_CERT_ID'] + end + + attr_writer :app_id, :dev_id, :cert_id end end end