Class: SourcedConfig::Locale::S3ConfigClient
- Inherits:
-
Object
- Object
- SourcedConfig::Locale::S3ConfigClient
- Defined in:
- lib/sourced_config/locale/s3_config_client.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
-
#initialize(bucket: ::SourcedConfig.configuration.configuration_bucket, region: ::SourcedConfig.configuration.configuration_bucket_region) ⇒ S3ConfigClient
constructor
A new instance of S3ConfigClient.
- #load(locale) ⇒ Object
Constructor Details
#initialize(bucket: ::SourcedConfig.configuration.configuration_bucket, region: ::SourcedConfig.configuration.configuration_bucket_region) ⇒ S3ConfigClient
Returns a new instance of S3ConfigClient.
8 9 10 11 12 13 14 |
# File 'lib/sourced_config/locale/s3_config_client.rb', line 8 def initialize( bucket: ::SourcedConfig.configuration.configuration_bucket, region: ::SourcedConfig.configuration.configuration_bucket_region ) @bucket = bucket @region = region end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
16 17 18 |
# File 'lib/sourced_config/locale/s3_config_client.rb', line 16 def bucket @bucket end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
16 17 18 |
# File 'lib/sourced_config/locale/s3_config_client.rb', line 16 def region @region end |
Instance Method Details
#load(locale) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/sourced_config/locale/s3_config_client.rb', line 18 def load(locale) Rails.logger.debug "Locale read from S3 locale file" file = "locales/#{locale}.yml" # TODO: make this configurable str = ::SourcedConfig::S3File.read(bucket, file, region) yaml = YAML.safe_load(str) root_node = yaml[locale.to_s] return {} if root_node.blank? root_node end |