Sha256: 9a3dd0849b8ec9b8a66d9879df7e9f5c17a2177fc09e7bb7a6c433bd8ced18db

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

module Spontaneous::Output::Store
  class Backend
    unless defined?(STATIC_PATH)
      STATIC_PATH, PROTECTED_PATH, DYNAMIC_PATH = %w(static protected dynamic).map(&:freeze)
    end

    def store_static(revision, key, template, transaction = nil)
      store(revision, STATIC_PATH, key, template, transaction)
    end

    def store_protected(revision, key, template, transaction = nil)
      store(revision, PROTECTED_PATH, key, template, transaction)
    end

    def store_dynamic(revision, key, template, transaction = nil)
      store(revision, DYNAMIC_PATH, key, template, transaction)
    end

    def load_static(revision, key)
      load(revision, STATIC_PATH, key)
    end

    def load_protected(revision, key)
      load(revision, PROTECTED_PATH, key)
    end

    def load_dynamic(revision, key)
      load(revision, DYNAMIC_PATH, key)
    end

    def output_key(output, dynamic = false)
      path = output.page.path
      ext  = output.extension(dynamic)
      case path
      when Spontaneous::SLASH
        "/index#{ext}"
      else
        "#{path}#{ext}"
      end
    end

    protected

    def store(revision, partition, path, template, transaction)
      raise NotImplementedError
    end

    def load(revision, partition, path)
      raise NotImplementedError
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 lib/spontaneous/output/store/backend.rb
spontaneous-0.2.0.beta9 lib/spontaneous/output/store/backend.rb
spontaneous-0.2.0.beta8 lib/spontaneous/output/store/backend.rb
spontaneous-0.2.0.beta7 lib/spontaneous/output/store/backend.rb
spontaneous-0.2.0.beta6 lib/spontaneous/output/store/backend.rb
spontaneous-0.2.0.beta5 lib/spontaneous/output/store/backend.rb