create a class to represent the structure of the data : PStore « Development « Ruby






create a class to represent the structure of the data


require 'pstore'

class Person
  attr_accessor :name, :job, :gender, :age
end

fred = Person.new
fred.name = "F"
fred.age = 45

laura = Person.new
laura.name = "L"
laura.age = 23



store = PStore.new("storagefile")
store.transaction do
  store[:people] ||= Array.new
  store[:people] << fred
  store[:people] << laura
end

 








Related examples in the same category

1.retrieve the data from the PStore database