Module: TDiary::IO::PluginPStore

Defined in:
lib/tdiary/io/plugin_pstore.rb

Instance Method Summary collapse

Instance Method Details

#plugin_close(storage_object) ⇒ Object



17
18
# File 'lib/tdiary/io/plugin_pstore.rb', line 17

def plugin_close(storage_object)
end

#plugin_open(conf) ⇒ Object

returning storage object



11
12
13
14
15
# File 'lib/tdiary/io/plugin_pstore.rb', line 11

def plugin_open(conf)
	storage = Pathname(conf.data_path) + 'plugin'
	storage.mkpath
	return storage
end

#plugin_transaction(storage_object, plugin_name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tdiary/io/plugin_pstore.rb', line 20

def plugin_transaction(storage_object, plugin_name)
	PStore.new(storage_object + "#{plugin_name}.db").transaction do |db|
		# define methods of plugin storage interface
		# PStore has 'delete' method as same function
		def db.get(key)
			self[key]
		end
		def db.set(key, value)
			self[key] = value
		end
		# def db.delete( key )
		#
		# end
		def db.keys
			self.roots
		end

		yield db
	end
end