Parent

Namespace

Files

Class/Module Index [+]

Quicksearch

Moneta::Transformer

Transforms keys and values (Marshal, YAML, JSON, Base64, MD5, ...). You can bypass the transformer (e.g. serialization) by using the `:raw` option.

@example Add `Moneta::Transformer` to proxy stack

Moneta.build do
  transformer :key => [:marshal, :escape], :value => [:marshal]
  adapter :File, :dir => 'data'
end

@example Bypass serialization

store.store('key', 'value', :raw => true)
store['key'] # raises an Exception
store.load('key', :raw => true) # returns 'value'

store['key'] = 'value'
store.load('key', :raw => true) # returns "\x04\bI\"\nvalue\x06:\x06ET"

@api public

Constants

KEY_TRANSFORMER

Allowed key transformers (Read it like a regular expression!)

TRANSFORMER

Available key/value transformers

VALUE_TRANSFORMER

Allowed value transformers (Read it like a regular expression!)

Public Class Methods

new(adapter, options = {}) click to toggle source

@param [Moneta store] adapter The underlying store @param [Hash] options @return [Transformer] new Moneta transformer @option options [Array] :key List of key transformers in the order in which they should be applied @option options [Array] :value List of value transformers in the order in which they should be applied @option options [String] :prefix Prefix string for key namespacing (Used by the :prefix key transformer) @option options [String] :secret HMAC secret to verify values (Used by the :hmac value transformer) @option options [Integer] :maxlen Maximum key length (Used by the :truncate key transformer)

# File lib/moneta/transformer.rb, line 32
def new(adapter, options = {})
  keys = [options[:key]].flatten.compact
  values = [options[:value]].flatten.compact
  raise ArgumentError, 'Option :key or :value is required' if keys.empty? && values.empty?
  options[:prefix] ||= '' if keys.include?(:prefix)
  name = class_name(keys, values)
  const_set(name, compile(keys, values)) unless const_defined?(name)
  const_get(name).original_new(adapter, options)
end
Also aliased as: original_new
original_new(adapter, options = {}) click to toggle source
Alias for: new

[Validate]

Generated with the Darkfish Rdoc Generator 2.