Sha256: a91f27afea34b9cfac5a1045e63c0b728e1ad789c94b2f500990c31b861ad8b8

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module LinkShrink
  module Config
    # @author Jonah Ruiz <jonah@pixelhipsters.com>
    # Configurable module for integrating with other URL APIs
    extend self

    # Returns and Sets API key to be used
    # @param api_key [String] API key to be used
    attr_accessor :api_key

    # Sets API to be used
    # @param api [String or Symbol] api to be used
    def api=(api)
      @api = LinkShrink::Shrinkers.const_get(api).new
    end

    # Returns API used
    # Unless an API is defined, it returns Google by default
    # @return [LinkShrink::Shrinkers::Google] instance
    def api
      @api || LinkShrink::Shrinkers::Google.new
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
link_shrink-0.0.6 lib/link_shrink/config.rb
link_shrink-0.0.5 lib/link_shrink/config.rb
link_shrink-0.0.4 lib/link_shrink/config.rb
link_shrink-0.0.3 lib/link_shrink/config.rb