Sha256: 2e09e75b82283cf052fc57e431f2ddcae9cc9af028d87c011a1d37c9153459ea

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

module Eco
  module API
    module Common
      module Session
        class BaseSession
          attr_accessor :session
          attr_accessor :environment, :config
          alias_method :enviro, :environment
          alias_method :enviro=, :environment=

          attr_reader  :api, :file_manager, :logger
          alias_method :fm, :file_manager

          include Session::Helpers

          def initialize(e)
            raise "Expected object Eco::API::Common::Session::Environment. Given: #{e.class}" unless e.is_a?(Environment)
            self.environment = e
          end

          def session
            enviro.session
          end

          def environment=(value)
            @environment = nil
            @environment = value if value.is_a?(Environment)
          end

          def config
            enviro.config
          end

          def api(version: nil)
            enviro.api(version: version)
          end

          def api?(version: nil)
            enviro.api?(version: version)
          end

          def file_manager
            enviro.file_manager
          end

          def mailer
            enviro.mailer
          end

          def mailer?
            enviro.mailer?
          end

          def sftp
            enviro.sftp
          end

          def sftp?
            enviro.sftp?
          end

          def s3uploader
            enviro.s3uploader
          end

          def s3uploader?
            enviro.s3uploader?
          end

          def logger
            enviro.logger
          end

          # TODO: paremeter for the exception
          def fatal(msg)
            logger.fatal(msg)
            raise msg
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/api/common/session/base_session.rb
eco-helpers-2.6.3 lib/eco/api/common/session/base_session.rb
eco-helpers-2.6.2 lib/eco/api/common/session/base_session.rb
eco-helpers-2.6.1 lib/eco/api/common/session/base_session.rb
eco-helpers-2.6.0 lib/eco/api/common/session/base_session.rb