Sha256: 9de3e582f68102db33ac2c363d58cc85b2527eefea88ed5804647d5bb6ac8e13

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

require 'ecoportal/api'

module Eco
  class Assets

    attr_reader :active_config

    def initialize
      @active_config = :default
    end

    def session(key: active_config)
      sessions[key] ||= Eco::API::Session.new(config(key: key))
      sessions[key].tap do |session|
        yield(session) if block_given?
      end
    end

    def sessions
      @sessions ||= {}
    end


    def config(key: active_config)
      configs[:default] ||= Eco::API::Session::Config.new(key)
      unless configs.key?(key)
        @active_config = key
        configs[key] = configs[:default].clone(key)
      end
      configs[key].tap do |config|
        yield(config) if block_given?
      end
    end

    def configs
      @configs ||= {}
    end
  end
end

ASSETS = Eco::Assets.new
#require_relative 'assets/'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eco-helpers-0.8.3 lib/eco/assets.rb
eco-helpers-0.8.2 lib/eco/assets.rb
eco-helpers-0.8.1 lib/eco/assets.rb