Sha256: 1a7e7c384a8d7bb54addc771ef4716906f1a7fa0b105fadc6387f6df1af816db

Contents?: true

Size: 499 Bytes

Versions: 27

Compression:

Stored size: 499 Bytes

Contents

module Api
  class Cache
    def self.cache(options = {}, &block)
      instance = new(options = {})
      instance.prepare_cache(&block)
      instance
    end

    def initialize(options = {}, &block)
    end

    def prepare_cache(&block)
      @cachable = block
    end

    def method_missing(m, *args, &block)
      key = "#{m}-#{args.to_json}-#{block.to_json}"
      # raise key
      output = @cachable.call.send(m, *args, &block)
      # raise output.inspect
      output
    end 
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rails-add_ons-0.6.0 app/caches/api/cache.rb
rails-add_ons-0.5.0 app/caches/api/cache.rb
rails-add_ons-0.4.1 app/caches/api/cache.rb
rails-add_ons-0.4.0 app/caches/api/cache.rb
rails-add_ons-0.3.2 app/caches/api/cache.rb
rails-add_ons-0.3.0 app/caches/api/cache.rb
rails-add_ons-0.2.0 app/caches/api/cache.rb