Skip to content

Commit

Permalink
Added connection and errors classes to the ActiveCouch namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
arunthampi committed Dec 3, 2007
1 parent 5cda02f commit 6e821a3
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion trunk/README
Expand Up @@ -10,7 +10,7 @@ Preliminarily,
- array (E.g. has_many :airports)

Nice to have extensions:
- schema.rb which will contain schemas for the ActiveCouch documents
- schema.rb which will contain schemas for ActiveCouch documents
- Migrations to change document schemas

Pre-requisites:
Expand Down
4 changes: 3 additions & 1 deletion trunk/active_couch.rb
@@ -1,4 +1,6 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))

require 'active_couch/base'
require 'active_couch/errors'
require 'active_couch/base'
require 'active_couch/connection'
12 changes: 6 additions & 6 deletions trunk/active_couch/base.rb
@@ -1,12 +1,12 @@
module ActiveCouch
class ActiveCouchError < StandardError
end

class IllegalArgumentError < ActiveCouchError
end

class Base
class << self
attr_writer :connection

def connection
@connection
end

def define_instance_variable(var_name, default_value)
unless var_name.is_a?(Symbol) || var_name.is_a?(String)
raise IllegalArgumentError, "#{sym.inspect} is neither a String nor a Symbol"
Expand Down
22 changes: 22 additions & 0 deletions trunk/active_couch/connection.rb
@@ -0,0 +1,22 @@
module ActiveCouch
class Connection
attr_accessor :server, :port

def initialize(options = {})
if options.has_key?(:server) && options.has_key?(:port)
@server = options[:server]
@port = options[:port]
else
raise ConfigurationMissingError, "Configuration hash must contain keys for server and port"
end
end

def get
nil
end

def put(data)

end
end
end
10 changes: 10 additions & 0 deletions trunk/active_couch/errors.rb
@@ -0,0 +1,10 @@
module ActiveCouch
class ActiveCouchError < StandardError
end

class IllegalArgumentError < ActiveCouchError
end

class ConfigurationMissingError < ActiveCouchError
end
end

0 comments on commit 6e821a3

Please sign in to comment.