aboutsummaryrefslogtreecommitdiff
path: root/core/store.rb
blob: 4d5e9a785a191c3c27f21afa7ecf563896bec147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'pstore'

module Dinobot
  module Core
    class Store
      attr_accessor :data

      def initialize(file)
        @store = PStore.new(file, true)

        read

        @data ||= {}
      end

      def read
        @store.transaction(true) do
          @data = @store[:data]
        end
      end

      def save
        @store.transaction do
          @store[:data] = @data
        end
      end
    end
  end
end