Sha256: 57e3a785546b4b2d4287d4beeb39b00293f1aeb3c0f821d6d5797aa00677092b

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

require "riak"

require "rico/object"

require "rico/array"
require "rico/list"
require "rico/set"
require "rico/sorted_set"
require "rico/value"

require "rico/resolver"

require "rico/version"

module Rico

  TYPES = {
    "Array" => "array",
    "List" => "list",
    "Set" => "set",
    "SortedSet" => "sset",
    "Value" => "value"
  }

  def self.configure
    yield self if block_given?
  end

  def self.bucket(key)
    namespaced_key = [@namespace, key].flatten.select(&:present?).join(":")
    @bucket_cache ||= {}
    @bucket_cache[namespaced_key] ||= riak.bucket(namespaced_key)
  end

  def self.namespace
    @namespace
  end

  def self.namespace=(namespace)
    @namespace = namespace
  end

  def self.options
    @options || {}
  end

  def self.options=(options)
    @options = options
  end

  def self.riak
    Thread.current[:riak] ||= Riak::Client.new(options)
  end
end

Riak::RObject.on_conflict(&Rico::Resolver.to_proc)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rico-0.2.0 lib/rico.rb