Class: Eco::API::Common::Session::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/api/common/session/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init = {}, session:) ⇒ Environment

Returns a new instance of Environment.

Parameters:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/eco/api/common/session/environment.rb', line 14

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/eco/api/common/session/environment.rb', line 6

def config
  @config
end

#file_managerObject (readonly) Also known as: fm

Returns the value of attribute file_manager.



7
8
9
# File 'lib/eco/api/common/session/environment.rb', line 7

def file_manager
  @file_manager
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/eco/api/common/session/environment.rb', line 7

def logger
  @logger
end

#mailerObject (readonly)

Returns the value of attribute mailer.



8
9
10
# File 'lib/eco/api/common/session/environment.rb', line 8

def mailer
  @mailer
end

#s3uploaderObject (readonly)

Returns the value of attribute s3uploader.



8
9
10
# File 'lib/eco/api/common/session/environment.rb', line 8

def s3uploader
  @s3uploader
end

#sessionObject (readonly)

Returns the value of attribute session.



6
7
8
# File 'lib/eco/api/common/session/environment.rb', line 6

def session
  @session
end

#sftpObject (readonly)

Returns the value of attribute sftp.



8
9
10
# File 'lib/eco/api/common/session/environment.rb', line 8

def sftp
  @sftp
end

Instance Method Details

#api(version: nil) ⇒ Object



56
57
58
# File 'lib/eco/api/common/session/environment.rb', line 56

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

#mailer?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/eco/api/common/session/environment.rb', line 32

def mailer?
  config.mailer.configured?
end

#s3uploader?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/eco/api/common/session/environment.rb', line 52

def s3uploader?
  config.s3storage.configured?
end

#sftp?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/eco/api/common/session/environment.rb', line 42

def sftp?
  config.sftp.configured?
end