Sha256: dd219c0917492521abdb8c480ffb304dfbab077480cc2e9a6f136d9a52d5ab2a

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

module Eco
  module API
    module Common
      module Session
        class BaseSession
          attr_writer :session, :config
          attr_reader :environment
          alias_method :enviro, :environment

          include Session::Helpers
          include Eco::Language::AuxiliarLogger

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

            self.environment = env
          end

          def session
            enviro.session
          end

          def environment=(value)
            @environment = nil
            @environment = value if value.is_a?(Environment)
          end
          alias_method :enviro=, :environment=

          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
          alias_method :fm, :file_manager

          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

6 entries across 6 versions & 1 rubygems

Version Path
eco-helpers-3.0.4 lib/eco/api/common/session/base_session.rb
eco-helpers-3.0.3 lib/eco/api/common/session/base_session.rb
eco-helpers-3.0.2 lib/eco/api/common/session/base_session.rb
eco-helpers-3.0.1 lib/eco/api/common/session/base_session.rb
eco-helpers-3.0.0 lib/eco/api/common/session/base_session.rb
eco-helpers-2.7.25 lib/eco/api/common/session/base_session.rb