Sha256: a00a9f29c21fdda49c5f076d96a57d70cf7d591625821d0b91d4794c1fc86f94

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 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

require_relative 'assets/language'


ASSETS = Eco::Assets.new

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eco-helpers-0.9.1 lib/eco/assets.rb
eco-helpers-0.8.4 lib/eco/assets.rb