~ubuntu-branches/ubuntu/trusty/ruby-moneta/trusty

« back to all changes in this revision

Viewing changes to lib/moneta/adapters/sdbm.rb

  • Committer: Package Import Robot
  • Author(s): Jérémy Bobbio
  • Date: 2013-05-14 09:40:52 UTC
  • mfrom: (1.2.1) (3.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130514094052-p8i17yyswpx6c1zc
Tags: 0.7.16-1
* Team upload.
* New upstream version.
* Remove transitional packages.
* Add Vcs-* fields.
* Fix a typo in debian/copyright.
* Add a Breaks for chef given the API has changed between 0.6 and 0.7.
* Refresh patches:
  - remove 0002-Mark-concurrent-increment-example-as-pending.patch:
    fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'sdbm'
 
2
 
 
3
module Moneta
 
4
  module Adapters
 
5
    # SDBM backend
 
6
    # @api public
 
7
    class SDBM < Memory
 
8
      # @param [Hash] options
 
9
      # @option options [String] :file Database file
 
10
      # @option options [::SDBM] :backend Use existing backend instance
 
11
      def initialize(options = {})
 
12
        @backend = options[:backend] ||
 
13
          begin
 
14
            raise ArgumentError, 'Option :file is required' unless options[:file]
 
15
            ::SDBM.new(options[:file])
 
16
          end
 
17
      end
 
18
 
 
19
      # (see Proxy#close)
 
20
      def close
 
21
        @backend.close
 
22
        nil
 
23
      end
 
24
    end
 
25
  end
 
26
end