Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
COPYING
History.txt
MIT-LICENSE
Manifest.txt
PostInstall.txt
README.rdoc
Rakefile
persistable.gemspec

README.rdoc

Persistable

Persistable is a library for persisting IO-Data into any storage you like. It provides adapters for in-memory storage, file storage and mogile-fs but can be easily extended with your own adapters.

Persistable has been harvested from project pkw.de of Caroo GmbH.

Download and Installation

Install the gem with the following command…

$ gem install persistable --source http://github.com/pkwde/persistable

Examples

class Image

  attr_accessor :name, :persistence_adapter

  def initialize(attributes = {})
    @name = attributes[:name]
    @persistence_data = attributes[:persistence_data]
  end

  def persistence_key
    self.name
  end

  def persistence_data
    @persistence_data
  end

  def persistence_data=(persistence_data)
    @persistence_data = persistence_data
  end

  def save_image_data
    persistence_adapter.write(self)
  end

  def load_image_data
    persistence_adapter.load(self)
  end

end

image = Image.new(:name => "foo", :persistence_data => File.open("/path/to/foo.jpg"))
image.persistence_adapter = Persistable::FSAdapter.new
image.save_image_data

new_but_same_image = Image.new(:name => "foo")
new_but_same_image.persistence_adapter = Persistable::FSAdapter.new
new_but_same_image.load_image_data

image.persistence_data == new_but_same_image.persistence_data

License

Copyright Caroo GmbH 2009

You may use, copy and redistribute this library under the same terms as Ruby itself or under the MIT license.

Something went wrong with that request. Please try again.