Sha256: e45e8a063928158f2b8f7d2dbc54e7c7aebe720304effa0ea20d4dc8f14fa16b

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.


module AWS::SessionStore::DynamoDB::Locking
  # This class gets and sets sessions
  # without a locking strategy.
  class Null < AWS::SessionStore::DynamoDB::Locking::Base
    # Retrieve session if it exists from the database by id.
    # Unpack the data once retrieved from the database.
    def get_session_data(env, sid)
      handle_error(env) do
        result = @config.dynamo_db_client.get_item(get_session_opts(sid))
        extract_data(env, result)
      end
    end

    # @return [Hash] Options for getting session.
    def get_session_opts(sid)
      merge_all(table_opts(sid), attr_opts)
    end

    # @return [String] Session data.
    def extract_data(env, result = nil)
      env['rack.initial_data'] = result[:item]["data"][:s] if result[:item]
      unpack_data(result[:item]["data"][:s]) if result[:item]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws-sessionstore-dynamodb-0.5.1 lib/aws/session_store/dynamo_db/locking/null.rb
aws-sessionstore-dynamodb-0.5.0 lib/aws/session_store/dynamo_db/locking/null.rb