Class: ICFS::ConfigS3
Overview
Configuration storage implemented in S3
Constant Summary
Constants inherited from Config
ICFS::Config::SetupCss, ICFS::Config::SetupRelTime, ICFS::Config::SetupTimezone
Instance Attribute Summary
Attributes inherited from Config
Instance Method Summary collapse
-
#initialize(setup, 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
#_generate, #clear, #default, #get, #set, #set?, #setup
Constructor Details
#initialize(setup, s3, bucket, prefix = nil) ⇒ ConfigS3
New instance
32 33 34 35 36 37 |
# File 'lib/icfs/config_s3.rb', line 32 def initialize(setup, s3, bucket, prefix=nil) super(setup) @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 _parse(json) return true rescue @data = {} return false end |
#save ⇒ Object
Save a user configuration
58 59 60 61 62 |
# File 'lib/icfs/config_s3.rb', line 58 def save() raise(RuntimeError, 'Save requires a user name') if !@unam json = _generate() @s3.put_object( bucket: @bck, key: _key(@unam), body: json ) end |