Class: HashBack::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/hashback/resource.rb

Overview

HashBack::Resource is an Object-Hash Mapping (OHM) tool for Ruby. It uses a Hash-like object as the persistent resource, which can be given on HashBack::Resource initialization.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.setup(source, key_method_sym, backend) ⇒ Object

Configures the persistent backend for this object. Configuration options:

  • source - the class to be persisted

  • key_method - a symbol representing the method that will return a unique identifier for this object when called on the instance

  • backend - a Hash-like Object (Moneta works well) for persisting this resource.



13
14
15
16
17
18
19
# File 'lib/hashback/resource.rb', line 13

def self.setup(source, key_method_sym, backend)
  source.__send__(:class_variable_set, :@@_backend, backend)
  source.__send__(:class_variable_set, :@@_key_method_sym, key_method_sym)

  source.__send__(:include, InstanceMethods)
  source.extend(ClassMethods)
end