Sha256: 49b39f8e13065d07d1367397699c4b1311b9ef4e307ab4d48f987c2cea6df8a6

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Eco
  module API
    module Common
      module Session
        class Environment

          include Common::People

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

          alias_method :fm, :file_manager

          def initialize(init = {})
            init = init.conf if init.is_a?(Environment)
            msg = "Wrong Session::Environment initializer. Expected Hash or Environment object. Given: #{init}"
            raise msg unless init.is_a?(SessionConfig)

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

          def new_api
            return nil unless config.apis.active_api

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

            api = config.api(log)

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

            @api = api
            api
          end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eco-helpers-0.6.0 lib/eco/api/common/session/environment.rb