class ICFS::ConfigS3
Configuration storage implemented in S3
Public Class Methods
new(setup, s3, bucket, prefix=nil)
click to toggle source
New instance
@param setup [Array] The setup @param s3 [Aws::S3::Client] the configured S3 client @param bucket [String] The bucket name @param prefix [String] Prefix to use for object keys
Calls superclass method
ICFS::Config::new
# File lib/icfs/config_s3.rb, line 32 def initialize(setup, s3, bucket, prefix=nil) super(setup) @s3 = s3 @bck = bucket @pre = prefix || '' end
Public Instance Methods
load(unam)
click to toggle source
(see Config#load
)
# 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()
click to toggle source
(see Config#save
)
# 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