No description, website, or topics provided.
Ruby
Pull request Compare This branch is 22 commits ahead of railsbros-dirk:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
History.txt
README.rdoc
Rakefile
persistable.gemspec

README.rdoc

Persistable

Description

Persistable is a library for persisting IO-Data into any storage you like. It provides adapters for in-memory storage, file storage, mogile-fs storage and a fog gem powered cloud storage 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 .