Module: Fathom::AttributeSystem

Defined in:
lib/fathom/behaviors/attribute_system.rb

Overview

This is a simple way to use thin Ruby classes to only store data values for attributes. In this way, we can have data models that can have various roles injected into them at runtime and perform fairly well. We can also have other kinds of data models mixed into Fathom, such as an ActiveRecord or DataMapper model, and we can just ignore this system altogether.

It is important that it is easy to set an attributes_proxy. Other Fathom gems (say fm-redis, if I were to write that gem) could override the AttributeSystem default attributes to store data in a Redis data store directly. This is what the set_attributes_proxy is designed to do here.

Example Usage: require ‘memcache’ CACHE = MemCache.new ‘localhost:11211’, :namespace => ‘my_project’ CACHE = => ‘special’

class MyClass

extend Fathom::Plugins
plugin Fathom::AttributeSystem

attribute :name
attribute :value, 1

def initialize(attrs={})
  @attributes = attrs
end

end

obj = MyClass.new(CACHE) obj.name # => special obj.value # => 1

Defined Under Namespace

Modules: ClassMethods, InstanceMethods