Sha256: c9fb80b286e2bc0b326c90c6ad8d661127eca430b0835aa7817bb1f3dacb0bbc

Contents?: true

Size: 432 Bytes

Versions: 3

Compression:

Stored size: 432 Bytes

Contents

module Hipbot
  module Cache
    extend ActiveSupport::Concern

    included do
      extend ClassMethods
    end

    def _cache
      @_cache ||= {}
    end

    module ClassMethods
      def attr_cache *attributes, &block
        attributes.each do |attr_name|
          define_method(attr_name) do
            _cache[attr_name] ||= block_given? ? instance_eval(&block) : []
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hipbot-1.0.4 lib/hipbot/utilities/cache.rb
hipbot-1.0.3 lib/hipbot/cache.rb
hipbot-1.0.0 lib/hipbot/cache.rb