Class: ICFS::ConfigS3
Overview
Configuration storage implemented in S3
Constant Summary
Constants inherited from Config
Instance Attribute Summary
Attributes inherited from Config
Instance Method Summary collapse
-
#initialize(defaults, s3, bucket, prefix = nil) ⇒ ConfigS3
constructor
New instance.
-
#load(unam) ⇒ Boolean
Load a user configuration.
-
#save ⇒ Object
Save a user configuration.
Methods inherited from Config
Constructor Details
#initialize(defaults, s3, bucket, prefix = nil) ⇒ ConfigS3
New instance
32 33 34 35 36 37 |
# File 'lib/icfs/config_s3.rb', line 32 def initialize(defaults, s3, bucket, prefix=nil) super(defaults) @s3 = s3 @bck = bucket @pre = prefix || '' end |
Instance Method Details
#load(unam) ⇒ Boolean
Load a user configuration
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/icfs/config_s3.rb', line 43 def load(unam) Items.validate(unam, 'User/Role/Group name', Items::FieldUsergrp) @unam = unam.dup json = @s3.get_object( bucket: @bck, key: _key(unam) ).body.read @data = Items.parse(json, 'Config values', Config::ValConfig) return true rescue @data = {} return false end |