Class: Eco::API::Common::Session::Environment
- Defined in:
- lib/eco/api/common/session/environment.rb
Instance Attribute Summary collapse
-
#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.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #api(version: nil) ⇒ Object
- #api?(version:) ⇒ Boolean
-
#initialize(init = {}, session:) ⇒ Environment
constructor
A new instance of Environment.
- #mailer ⇒ Object
- #mailer? ⇒ Boolean
- #s3uploader ⇒ Object
- #s3uploader? ⇒ Boolean
- #sftp ⇒ Object
- #sftp? ⇒ Boolean
Constructor Details
#initialize(init = {}, session:) ⇒ Environment
Returns a new instance of Environment.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eco/api/common/session/environment.rb', line 13 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) invalid_session = session && !session.is_a?(Eco::API::Session) raise "Expected an Eco::API::Session object. Given: #{session}" if invalid_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
#config ⇒ Object (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_manager ⇒ Object (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 |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/eco/api/common/session/environment.rb', line 7 def logger @logger end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
6 7 8 |
# File 'lib/eco/api/common/session/environment.rb', line 6 def session @session end |
Instance Method Details
#api(version: nil) ⇒ Object
55 56 57 |
# File 'lib/eco/api/common/session/environment.rb', line 55 def api(version: nil) config.api(logger, version: version) end |
#api?(version:) ⇒ Boolean
59 60 61 |
# File 'lib/eco/api/common/session/environment.rb', line 59 def api?(version:) config.apis.active_api.version_available?(version) end |
#mailer ⇒ Object
28 29 30 31 |
# File 'lib/eco/api/common/session/environment.rb', line 28 def mailer return nil unless mailer? @mailer ||= Eco::API::Common::Session::Mailer.new(enviro: self) end |
#mailer? ⇒ Boolean
33 34 35 |
# File 'lib/eco/api/common/session/environment.rb', line 33 def mailer? config.mailer.configured? end |
#s3uploader ⇒ Object
46 47 48 49 |
# File 'lib/eco/api/common/session/environment.rb', line 46 def s3uploader return nil unless s3uploader? @s3uploader ||= Eco::API::Common::Session::S3Uploader.new(enviro: self) end |
#s3uploader? ⇒ Boolean
51 52 53 |
# File 'lib/eco/api/common/session/environment.rb', line 51 def s3uploader? config.s3storage.configured? end |
#sftp ⇒ Object
37 38 39 40 |
# File 'lib/eco/api/common/session/environment.rb', line 37 def sftp return nil unless sftp? @sftp ||= Eco::API::Common::Session::SFTP.new(enviro: self) end |
#sftp? ⇒ Boolean
42 43 44 |
# File 'lib/eco/api/common/session/environment.rb', line 42 def sftp? config.sftp.configured? end |