Sha256: 38a015ffb0fbe86c455caad9408226ed6564306f774b387d6bf90d8b0278fdb1

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

module Saviour
  class ReadOnlyFile
    attr_reader :persisted_path

    def initialize(persisted_path)
      @persisted_path = persisted_path
    end

    def exists?
      persisted? && Config.storage.exists?(@persisted_path)
    end

    def read
      return nil unless persisted?
      Config.storage.read(@persisted_path)
    end

    def public_url
      return nil unless persisted?
      Config.storage.public_url(@persisted_path)
    end
    alias_method :url, :public_url

    def ==(another_file)
      return false unless another_file.is_a?(Saviour::File) || another_file.is_a?(ReadOnlyFile)
      return false unless another_file.persisted?

      another_file.persisted_path == persisted_path
    end

    def persisted?
      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saviour-0.5.11 lib/saviour/read_only_file.rb