Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
getfitter-core / lib / core / configuration.rb
Size: Mime:
module Core
  class Configuration
    # Redis URL
    attr_accessor :redis_url
    # Token for Stripe
    attr_accessor :stripe_token
    # Token for the OpenCage Geocoder
    attr_accessor :opencage_token
    # Tokens for Facebook
    attr_accessor :facebook_key, :facebook_secret
    # Tokens for Google+
    attr_accessor :gplus_key, :gplus_secret

    # Create a new Configuration instance
    #
    # This also allows providing a hash of configuration values, which calls
    # the accessor methods to full in the values.
    def initialize(opts = {})
      opts.each do |k, v|
        send("#{k}=".to_sym, v)
      end
    end

    # Hash representation of the configuration object.
    def to_h
      { redis_url: @redis_url, stripe_token: @stripe_token,
        opencage_token: @opencage_token, facebook_key: @facebook_key,
        facebook_secret: @facebook_secret, gplus_key: @gplus_key,
        gplus_secret: @gplus_secret }
    end

    # String representation of the configuration.
    def to_s
      "#<#{self.class.name}:#{object_id} redis_url=#{@redis_url} "\
      "stripe_token=#{@stripe_token} opencage_token=#{@opencage_token} "\
      "facebook_key=#{@facebook_key} facebook_secret=#{@facebook_secret} "\
      "gplus_key=#{@gplus_key} gplus_secret=#{@gplus_secret}>"
    end
  end

  class << self
    attr_accessor :configuration
  end

  # Support for a configuration block.
  def self.configure
    yield configuration if block_given?
  end

  # The default configuration object.
  def self.configuration
    @configuration ||= Configuration.new
  end
end