class Azure::Directory::YamlTokenStore

Public Class Methods

new(yaml_file) click to toggle source
# File lib/azure/directory/config.rb, line 127
def initialize(yaml_file)
        @yaml_file = yaml_file
        @yaml_data = YAML::load( yaml_file.open )
        @yaml_data = {} unless @yaml_data.is_a?(Hash)
end

Public Instance Methods

load( scope_name ) click to toggle source
# File lib/azure/directory/config.rb, line 139
def load( scope_name )
        data = @yaml_data[Rails.env.to_s] and data = data[scope_name.to_s] and data.slice('access_token', 'token_type', 'expires_at')
end
save( scope_name, token_hash ) click to toggle source
# File lib/azure/directory/config.rb, line 133
def save( scope_name, token_hash )
        data = (@yaml_data[Rails.env.to_s] ||= {})
        data[scope_name.to_s] = token_hash
        File.open(@yaml_file, 'w') { |file| file.write( YAML::dump(@yaml_data) ) }
end