Sha256: fa8be5b909fdb4fb4d50aff92a3bbbcc2cb3acd892a762de7cfe5c7b33d09a83

Contents?: true

Size: 1.93 KB

Versions: 108

Compression:

Stored size: 1.93 KB

Contents

module Eco
  module API
    module Common
      module Session
        class Environment
          attr_reader :config, :session
          attr_reader :file_manager, :logger
          attr_reader :mailer, :sftp, :s3uploader

          alias_method :fm, :file_manager

          #@param init [Eco::API::Common::Session::Environment] object to ini the session environment
          #@param session [Eco::API::Session, nil] the current session
          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)
          end

          def mailer
            if mailer?
              @mailer      ||= Eco::API::Common::Session::Mailer.new(enviro: self)
            end
          end

          def mailer?
            config.mailer.configured?
          end

          def sftp
            if sftp?
              @sftp        ||= Eco::API::Common::Session::SFTP.new(enviro: self)
            end
          end

          def sftp?
            config.sftp.configured?
          end

          def s3uploader
            if s3uploader?
              @s3uploader  ||= Eco::API::Common::Session::S3Uploader.new(enviro: self)
            end
          end

          def s3uploader?
            config.s3storage.configured?
          end

          def api(version: nil)
            config.api(logger, version: version)
          end

        end
      end
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
eco-helpers-2.0.55 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.54 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.53 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.52 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.51 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.50 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.49 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.48 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.47 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.46 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.45 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.44 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.43 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.42 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.41 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.40 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.39 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.38 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.37 lib/eco/api/common/session/environment.rb
eco-helpers-2.0.36 lib/eco/api/common/session/environment.rb