lib/blendris/reference_base.rb in blendris-0.5 vs lib/blendris/reference_base.rb in blendris-0.6

- old
+ new

@@ -1,21 +1,19 @@ module Blendris # RedisReferenceBase holds the methods that are common to # RedisReference objects and RedisReferenceSet objects. - class RedisReferenceBase + class RedisReferenceBase < RedisNode - include RedisNode extend RedisAccessor def initialize(key, options = {}) + super key, options + @model = options[:model] - @key = sanitize_key(key) @reverse = options[:reverse] - @options = options - @on_change = options[:on_change] @klass = options[:class] || Model @klass = constantize(camelize @klass) if @klass.kind_of? String unless @klass.ancestors.include? Model @@ -23,17 +21,17 @@ end end def apply_reverse_add(value) if @reverse && value - reverse = value.redis_symbol(@reverse) + reverse = value[@reverse] reverse.assign_ref(@model) if !reverse.references @model end end def apply_reverse_delete(value) if @reverse && value - reverse = value.redis_symbol(@reverse) + reverse = value[@reverse] reverse.remove_ref(@model) if reverse.references @model end end def self.cast_to_redis(obj, options = {})