Module: Ripple::Properties

Defined in:
ripple/lib/ripple/properties.rb

Overview

Adds the ability to declare properties on your Ripple::Document class. Properties will automatically generate accessor (get/set/query) methods and handle type-casting between your Ruby type and JSON-compatible types.

Instance Method Summary (collapse)

Instance Method Details

- (Hash) properties

The properties defined on the document

Returns:

  • (Hash)

    the properties defined on the document



31
32
33
# File 'ripple/lib/ripple/properties.rb', line 31

def properties
  @properties ||= {}.with_indifferent_access
end

- (Object) property(key, type, options = {})



35
36
37
38
# File 'ripple/lib/ripple/properties.rb', line 35

def property(key, type, options={})
  prop = Property.new(key, type, options)
  properties[prop.key] = prop
end