Sha256: b5fad7388bc125af68f9583ce63a9986870a4a9091c42ca39978c38ae11f7e9d

Contents?: true

Size: 566 Bytes

Versions: 5

Compression:

Stored size: 566 Bytes

Contents

class Redis
  class Settings
    module ActiveRecord
      def self.included(base)
        base.class_eval do
          include InstanceMethods
          after_destroy :clear_settings
        end
      end

      module InstanceMethods
        def settings
          raise Redis::Settings::NewRecordError if new_record?
          @settings ||= Settings.new("#{self.class.name.underscore}/#{id}")
        end

        def clear_settings
          settings.clear
        end
      end
    end
  end
end

ActiveRecord::Base.send :include, Redis::Settings::ActiveRecord

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redis-settings-0.2.2 lib/redis/settings/active_record.rb
redis-settings-0.2.1 lib/redis/settings/active_record.rb
redis-settings-0.2.0 lib/redis/settings/active_record.rb
redis-settings-0.1.1 lib/redis/settings/active_record.rb
redis-settings-0.1.0 lib/redis/settings/active_record.rb