Class: Azure::SAS::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/sas/options.rb

Overview

Holds all possible options for a SAS generation

Constant Summary collapse

FIELDS =
{
  signedresource: :sr,
  signedstart: :st,
  signedexpiry: :se,
  signedpermissions: :sp,
  identifier: :si
}.freeze

Instance Method Summary collapse

Instance Method Details

#to_query_valuesObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/azure/sas/options.rb', line 26

def to_query_values
  {
    signedresource: signedresource,
    signedstart: signedstart && signedstart.utc.iso8601,
    signedexpiry: signedexpiry && signedexpiry.utc.iso8601,
    signedpermissions: signedpermissions,
    identifier: identifier
  }.map do |key, value|
    [FIELDS.fetch(key), value] if value
  end.compact.to_h
end

#validate!Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/azure/sas/options.rb', line 15

def validate!
  validate_option_value(
    :signedresource,
    signedresource,
    BLOB_RESOURCE, CONTAINER_RESOURCE, nil
  )

  validate_option_type(:signedstart, signedstart, Time)
  validate_option_type(:signedexpiry, signedstart, Time)
end