Module: Ripple

Defined in:
ripple/lib/ripple.rb,
ripple/lib/ripple/railtie.rb,
ripple/lib/ripple/document.rb,
ripple/lib/ripple/callbacks.rb,
ripple/lib/ripple/timestamps.rb,
ripple/lib/ripple/properties.rb,
ripple/lib/ripple/inspection.rb,
ripple/lib/ripple/conversion.rb,
ripple/lib/ripple/observable.rb,
ripple/lib/ripple/validations.rb,
ripple/lib/ripple/translation.rb,
ripple/lib/ripple/document/key.rb,
ripple/lib/ripple/associations.rb,
ripple/lib/ripple/serialization.rb,
ripple/lib/ripple/document/finders.rb,
ripple/lib/ripple/associations/one.rb,
ripple/lib/ripple/embedded_document.rb,
ripple/lib/ripple/nested_attributes.rb,
ripple/lib/ripple/attribute_methods.rb,
ripple/lib/ripple/associations/many.rb,
ripple/lib/ripple/associations/proxy.rb,
ripple/lib/ripple/associations/linked.rb,
ripple/lib/ripple/document/persistence.rb,
riak-sessions/lib/ripple/session_store.rb,
ripple/lib/ripple/associations/embedded.rb,
ripple/lib/ripple/attribute_methods/read.rb,
ripple/lib/ripple/document/bucket_access.rb,
ripple/lib/ripple/property_type_mismatch.rb,
ripple/lib/ripple/attribute_methods/write.rb,
ripple/lib/ripple/attribute_methods/query.rb,
ripple/lib/ripple/attribute_methods/dirty.rb,
ripple/lib/ripple/embedded_document/finders.rb,
ripple/lib/ripple/associations/instantiators.rb,
ripple/lib/rails/generators/ripple_generator.rb,
ripple/lib/ripple/embedded_document/persistence.rb,
ripple/lib/ripple/associations/one_linked_proxy.rb,
ripple/lib/ripple/associations/many_linked_proxy.rb,
ripple/lib/ripple/associations/one_embedded_proxy.rb,
ripple/lib/rails/generators/ripple/js/js_generator.rb,
ripple/lib/ripple/associations/many_embedded_proxy.rb,
ripple/lib/ripple/validations/associated_validator.rb,
ripple/lib/rails/generators/ripple/test/test_generator.rb,
ripple/lib/rails/generators/ripple/model/model_generator.rb,
ripple/lib/rails/generators/ripple/observer/observer_generator.rb,
ripple/lib/rails/generators/ripple/configuration/configuration_generator.rb

Overview

Contains the classes and modules related to the ODM built on top of the basic Riak client.

Defined Under Namespace

Modules: Associations, AttributeMethods, Callbacks, Conversion, Document, EmbeddedDocument, Generators, Inspection, NestedAttributes, Observable, Properties, Serialization, Timestamps, Translation, Validations Classes: Association, DocumentInvalid, DocumentNotFound, MissingConfiguration, NoRootDocument, Property, PropertyTypeMismatch, Railtie, SessionStore

Class Method Summary (collapse)

Class Method Details

+ (Riak::Client) client

The client for the current thread.

Returns:



29
30
31
# File 'ripple/lib/ripple.rb', line 29

def client
  Thread.current[:ripple_client] ||= Riak::Client.new(client_config)
end

+ (Object) client=(value)

Sets the client for the current thread.

Parameters:



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

def client=(value)
  Thread.current[:ripple_client] = value
end

+ (Object) config

Reads the global Ripple configuration.



46
47
48
# File 'ripple/lib/ripple.rb', line 46

def config
  @config ||= {}
end

+ (Object) config=(hash)

Sets the global Ripple configuration.



40
41
42
43
# File 'ripple/lib/ripple.rb', line 40

def config=(hash)
  self.client = nil
  @config = hash.symbolize_keys
end

+ (Symbol) date_format

The format in which date/time objects will be serialized to strings in JSON. Defaults to :iso8601, and can be set in Ripple.config.

Returns:

  • (Symbol)

    the date format



54
55
56
# File 'ripple/lib/ripple.rb', line 54

def date_format
  (config[:date_format] ||= :iso8601).to_sym
end

+ (Object) date_format=(format)

Sets the format for date/time objects that are serialized to JSON.

Parameters:

  • format (Symbol)

    the date format



61
62
63
# File 'ripple/lib/ripple.rb', line 61

def date_format=(format)
  config[:date_format] = format.to_sym
end

+ (Object) load_configuration(config_file, config_keys = [:ripple]) Also known as: load_config

Loads the Ripple configuration from a given YAML file. Evaluates the configuration with ERB before loading.



67
68
69
70
71
72
73
74
# File 'ripple/lib/ripple.rb', line 67

def load_configuration(config_file, config_keys = [:ripple])
  config_file = File.expand_path(config_file)
  config_hash = YAML.load(ERB.new(File.read(config_file)).result).with_indifferent_access
  config_keys.each {|k| config_hash = config_hash[k]}
  self.config = config_hash || {}
rescue Errno::ENOENT
  raise Ripple::MissingConfiguration.new(config_file)
end