Module: ARMS

Defined in:
lib/arms.rb,
lib/arms.rb,
lib/arms/version.rb,
lib/arms/multi_coder.rb,
lib/arms/struct_coder.rb,
lib/arms/indifferent_hashes_coder.rb

Defined Under Namespace

Modules: ActiveRecord Classes: DumpError, Error, IndifferentHashesCoder, InvalidCoder, LoadError, MultiCoder, ShortcutInvocation, StructCoder

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.register_coder_shortcut(key) {|shortcut_invocation| ... } ⇒ Object

adds a shortcut which can be used with ActiveRecord::Base.arms_serialize. the key is usually a symbol, but may be anything. the given block is called by arms_serialize with an ARMS::ShortcutInvocation object, and must result in a coder.

Yield Parameters:

Yield Returns:

  • (#load, #dump)

    a coder which responds to #load and #dump

Raises:

  • (ArgumentError)


41
42
43
44
45
# File 'lib/arms.rb', line 41

def register_coder_shortcut(key, &coderproc)
  raise(ArgumentError, "already registered shortcut: #{key}") if @coder_shortcuts.key?(key)
  @coder_shortcuts[key] = coderproc
  nil
end