Class: Moneta::Transformer

### Home Classes Methods

### In Files

- lib/moneta/transformer.rb
- lib/moneta/transformer/config.rb
- lib/moneta/transformer/helper.rb

### Parent

Moneta::Proxy

### Namespace

- MODULE Moneta::Transformer::Helper

### Methods

- ::new
- ::original_new

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Moneta
- Moneta::Adapters
- Moneta::Adapters::ActiveRecord
- Moneta::Adapters::Cassandra
- Moneta::Adapters::Client
- Moneta::Adapters::Cookie
- Moneta::Adapters::Couch
- Moneta::Adapters::DBM
- Moneta::Adapters::DataMapper
- Moneta::Adapters::DataMapper::Store
- Moneta::Adapters::Daybreak
- Moneta::Adapters::File
- Moneta::Adapters::Fog
- Moneta::Adapters::GDBM
- Moneta::Adapters::HBase
- Moneta::Adapters::KyotoCabinet
- Moneta::Adapters::LMDB
- Moneta::Adapters::LRUHash
- Moneta::Adapters::LRUHash::Entry
- Moneta::Adapters::LevelDB
- Moneta::Adapters::LocalMemCache
- Moneta::Adapters::MemcachedDalli
- Moneta::Adapters::MemcachedNative
- Moneta::Adapters::Memory
- Moneta::Adapters::Mongo
- Moneta::Adapters::Null
- Moneta::Adapters::PStore
- Moneta::Adapters::Redis
- Moneta::Adapters::RestClient
- Moneta::Adapters::Riak
- Moneta::Adapters::SDBM
- Moneta::Adapters::Sequel
- Moneta::Adapters::Sqlite
- Moneta::Adapters::TDB
- Moneta::Adapters::TokyoCabinet
- Moneta::Adapters::TokyoTyrant
- Moneta::Adapters::YAML
- Moneta::Builder
- Moneta::Cache
- Moneta::Cache::DSL
- Moneta::CreateSupport
- Moneta::Defaults
- Moneta::Defaults::ClassMethods
- Moneta::Expires
- Moneta::ExpiresSupport
- Moneta::HashAdapter
- Moneta::IncrementSupport
- Moneta::Lock
- Moneta::Logger
- Moneta::Logger::Format
- Moneta::Mutex
- Moneta::OptionMerger
- Moneta::OptionSupport
- Moneta::Pool
- Moneta::Proxy
- Moneta::Semaphore
- Moneta::Server
- Moneta::Shared
- Moneta::Stack
- Moneta::Stack::DSL
- Moneta::SynchronizePrimitive
- Moneta::Transformer
- Moneta::Transformer::Helper
- Moneta::Utils
- Moneta::WeakCreate
- Moneta::WeakIncrement
- Moneta::Wrapper
- Rack
- Rack::Cache
- Rack::Cache::EntityStore
- Rack::Cache::EntityStore::MONETA
- Rack::Cache::EntityStore::Moneta
- Rack::Cache::MetaStore
- Rack::Cache::MetaStore::MONETA
- Rack::Cache::MetaStore::Moneta
- Rack::Cache::MonetaResolver
- Rack::MonetaCookies
- Rack::MonetaRest
- Rack::MonetaStore
- Rack::Session
- Rack::Session::Moneta
- ActionDispatch
- ActionDispatch::Session
- ActionDispatch::Session::MonetaStore
- ActiveSupport
- ActiveSupport::Cache
- ActiveSupport::Cache::MonetaStore

No matching classes.

# 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.