module Redis::Persistence

Redis::Persistence is a lightweight object persistence framework, fully compatible with ActiveModel and based on Redis.

Features:

Basic example:

class Article
  include Redis::Persistence

  property :title
  property :body
  property :author, :default  => '(Unknown)'
  property :created
end

Article.create title: 'Hello World!', body: 'So, in the beginning...', created: Time.now.utc
article = Article.find(1)
# => <Article: {"id"=>1, "title"=>"Hello World!", ...}>
article.title
# => Hello World!
article.created.class
# => Time

See the examples/article.rb for full example.

Constants

DEFAULT_FAMILY
VERSION

Public Class Methods

__redis() click to toggle source
# File lib/redis/persistence.rb, line 70
def self.__redis
  Redis::Persistence.config.redis
end
config() click to toggle source
# File lib/redis/persistence.rb, line 54
def self.config
  @__config ||= Hashr.new
end
configure() { |config| ... } click to toggle source
# File lib/redis/persistence.rb, line 58
def self.configure
  yield config
end
included(base) click to toggle source
# File lib/redis/persistence.rb, line 62
def self.included(base)
  base.class_eval do
    include ActiveModelIntegration
    self.include_root_in_json = false

    extend  ClassMethods
    include InstanceMethods

    def self.__redis
      Redis::Persistence.config.redis
    end

    def __redis
      self.class.__redis
    end
  end
end

Public Instance Methods

__redis() click to toggle source
# File lib/redis/persistence.rb, line 74
def __redis
  self.class.__redis
end