Skip to content

code-later/persistable

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
COPYING
MIT
MIT-LICENSE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages