Sha256: 5c9b0d2ba899da844c947055e93b7c8ab952d0a85141b97f4ccddb3bc13bf4cf

Contents?: true

Size: 1.53 KB

Versions: 23

Compression:

Stored size: 1.53 KB

Contents

module Eco
  module API
    module Common
      module Session
        class Environment

          include Common::People

          attr_reader :config, :session
          attr_reader :api #, :host, :version
          attr_reader :file_manager, :logger

          alias_method :fm, :file_manager

          def initialize(init = {}, session:)
            init = init.conf if init.is_a?(Environment)
            msg = "Expected object Eco::API::Session::Config or Environment. Given: #{init}"
            raise msg unless init.is_a?(Eco::API::Session::Config)
            raise "Expected an Eco::API::Session object. Given: #{session}" if session  && !session.is_a?(Eco::API::Session)

            @config  = init
            @session = session
            @file_manager = Eco::API::Common::Session::FileManager.new(enviro: self)
            @logger       = Eco::API::Common::Session::Logger.new(enviro: self)
            new_api
          end

          def new_api
            return nil unless config.apis.active_api

            log_connection = config.logger.log_connection?
            logg = log_connection ? logger : ::Logger.new(IO::NULL)

            api = config.api(logg)

            unless log_connection
              logger.info("Created connection pointing to '#{config.apis.active_api.host}' in '#{config.apis.active_api.mode}' mode")
              api.logger.level = ::Logger::UNKNOWN
            end

            @api = api
            api
          end

        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
eco-helpers-1.0.10 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.9 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.8 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.7 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.6 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.5 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.4 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.3 lib/eco/api/common/session/environment.rb
eco-helpers-0.9.5 lib/eco/api/common/session/environment.rb
eco-helpers-1.0.2 lib/eco/api/common/session/environment.rb
eco-helpers-0.9.4 lib/eco/api/common/session/environment.rb
eco-helpers-0.9.3 lib/eco/api/common/session/environment.rb
eco-helpers-0.9.2 lib/eco/api/common/session/environment.rb
eco-helpers-0.9.1 lib/eco/api/common/session/environment.rb
eco-helpers-0.8.4 lib/eco/api/common/session/environment.rb
eco-helpers-0.8.3 lib/eco/api/common/session/environment.rb
eco-helpers-0.8.2 lib/eco/api/common/session/environment.rb
eco-helpers-0.8.1 lib/eco/api/common/session/environment.rb
eco-helpers-0.7.2 lib/eco/api/common/session/environment.rb
eco-helpers-0.7.1 lib/eco/api/common/session/environment.rb