Module: Ripple::Document::Key::ClassMethods

Defined in:
lib/ripple/document/key.rb

Instance Method Summary collapse

Instance Method Details

#key_on(prop) ⇒ Object

Defines the key to be derived from a property.

Parameters:

  • prop (String, Symbol)

    the property to derive the key from



11
12
13
14
15
16
17
# File 'lib/ripple/document/key.rb', line 11

def key_on(prop)
  prop = prop.to_sym

  define_method(:key) { send(prop).to_s }
  define_method(:key=) { |v| send(:"#{prop}=", v) }
  define_method(:key_attr) { prop }
end