Class: Eco::API::Common::Session::Environment
- Inherits:
-
Object
- Object
- Eco::API::Common::Session::Environment
- Includes:
- People
- Defined in:
- lib/eco/api/common/session/environment.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
, :host, :version.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file_manager ⇒ Object
(also: #fm)
readonly
Returns the value of attribute file_manager.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#mailer ⇒ Object
readonly
Returns the value of attribute mailer.
-
#s3uploader ⇒ Object
readonly
Returns the value of attribute s3uploader.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#sftp ⇒ Object
readonly
Returns the value of attribute sftp.
Instance Method Summary collapse
-
#initialize(init = {}, session:) ⇒ Environment
constructor
A new instance of Environment.
- #mailer? ⇒ Boolean
- #new_api ⇒ Object
- #s3uploader? ⇒ Boolean
- #sftp? ⇒ Boolean
Constructor Details
#initialize(init = {}, session:) ⇒ Environment
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/eco/api/common/session/environment.rb', line 18 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
#api ⇒ Object (readonly)
, :host, :version
10 11 12 |
# File 'lib/eco/api/common/session/environment.rb', line 10 def api @api end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/eco/api/common/session/environment.rb', line 9 def config @config end |
#file_manager ⇒ Object (readonly) Also known as: fm
Returns the value of attribute file_manager.
11 12 13 |
# File 'lib/eco/api/common/session/environment.rb', line 11 def file_manager @file_manager end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
11 12 13 |
# File 'lib/eco/api/common/session/environment.rb', line 11 def logger @logger end |
#mailer ⇒ Object (readonly)
Returns the value of attribute mailer.
12 13 14 |
# File 'lib/eco/api/common/session/environment.rb', line 12 def mailer @mailer end |
#s3uploader ⇒ Object (readonly)
Returns the value of attribute s3uploader.
12 13 14 |
# File 'lib/eco/api/common/session/environment.rb', line 12 def s3uploader @s3uploader end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
9 10 11 |
# File 'lib/eco/api/common/session/environment.rb', line 9 def session @session end |
#sftp ⇒ Object (readonly)
Returns the value of attribute sftp.
12 13 14 |
# File 'lib/eco/api/common/session/environment.rb', line 12 def sftp @sftp end |
Instance Method Details
#mailer? ⇒ Boolean
36 37 38 |
# File 'lib/eco/api/common/session/environment.rb', line 36 def mailer? config.mailer.configured? end |
#new_api ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/eco/api/common/session/environment.rb', line 64 def new_api return nil unless config.apis.active_api log_connection = config.logger.log_connection? logg = log_connection ? logger : ::Logger.new(IO::NULL) api = config.api(logg) 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 |
#s3uploader? ⇒ Boolean
56 57 58 |
# File 'lib/eco/api/common/session/environment.rb', line 56 def s3uploader? config.s3storage.configured? end |
#sftp? ⇒ Boolean
46 47 48 |
# File 'lib/eco/api/common/session/environment.rb', line 46 def sftp? config.sftp.configured? end |