Sha256: 70efe936b572e22da3af98f2605047eb040ae00a68d8be7dd8c63017250d0a90

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

module Exegesis
  module Database
    module Singleton
      
      include Exegesis::Database::InstanceMethods
      include Exegesis::Database::Designs
      include Exegesis::Database::Documents
      
      def uri(addr=nil)
        if addr
          if addr.match(Exegesis::Database::URI_PATTERN)
            @server   = Exegesis::Server.new($1)
            @uri      = "#{@server.uri}/#{$2}"
          elsif addr.match(Exegesis::Database::NAME_PATTERN)
            @server   = Exegesis::Server.new
            @uri      = "#{@server.uri}/#{addr}"
          else
            raise ArgumentError, "does not match a valid database name/uri pattern"
          end
          begin
            @server.get @uri
          rescue RestClient::ResourceNotFound
            @server.put @uri
          end
          @uri
        else
          @uri || uri(Exegesis.nameify(name))
        end
      end
    
      def server
        @server
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mattly-exegesis-0.2.8 lib/exegesis/database/singleton.rb