Module: RedisProps::ClassMethods

Defined in:
lib/redis_props.rb

Instance Method Summary collapse

Instance Method Details

#props(context_name = "", opts = {}, &block) ⇒ Object

Specifies a set of properties to be stored in Redis for this ActiveRecord object instance.

Options are:

<tt>:defer</tt> - Specifies that the attributes in this context should be flushed
to Redis only when the ActiveRecord object is saved. This option defaults to +false+
and the default behavior is to read and write values to/from Redis immediately as
they are accessed.

<tt>:touch</tt> - Specifies that this ActiveRecord object's +updated_at+ field should
be updated on save (aka "touching the object") when you write new attributes values,
even if no database-backed attributes were changed. This option is occasionally
vital when dealing with cache invalidation in Rails. If you specify
a symbol (vs :true), then that attribute will be updated with the current
time instead of the updated_at/on attribute.
This option defaults to +false+.


36
37
38
# File 'lib/redis_props.rb', line 36

def props(context_name="", opts={}, &block)
  PropsContext.new(context_name, self, opts, block)
end

#rObject



15
16
17
# File 'lib/redis_props.rb', line 15

def r
  @redis_nest ||= Nest.new(name)
end