Sha256: fc3afcdc11c31e729d3f3e97735391bd609478baafdcb23fb59835a9919c5b50

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 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?(Eco::API::SessionConfig)

            @config = init
            @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?
            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}' 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

10 entries across 10 versions & 1 rubygems

Version Path
eco-helpers-0.6.13 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.12 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.11 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.9 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.8 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.7 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.6 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.5 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.4 lib/eco/api/common/session/environment.rb
eco-helpers-0.6.3 lib/eco/api/common/session/environment.rb