odba 1.1.8 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/odba/marshal.rb CHANGED
@@ -2,20 +2,21 @@
2
2
  #-- Marshal -- odba -- 29.04.2004 -- hwyss@ywesee.com rwaltert@ywesee.com mwalder@ywesee.com
3
3
 
4
4
  module ODBA
5
- # Marshal is a simple extension of ::Marshal. To be able to store our data
6
- # using the DBI-Interface, we need to escape invalid characters from the
7
- # standard binary dump.
8
- module Marshal
9
- def Marshal.dump(obj)
10
- binary = ::Marshal.dump(obj)
11
- binary.unpack('H*').first
12
- end
13
- def Marshal.load(hexdump)
14
- binary = [hexdump].pack('H*')
15
- ::Marshal.load(binary)
5
+ # Marshal is a simple extension of ::Marshal. To be able to store our data
6
+ # using the DBI-Interface, we need to escape invalid characters from the
7
+ # standard binary dump.
8
+ module Marshal
9
+ def self.dump(obj)
10
+ binary = ::Marshal.dump(obj)
11
+ binary.unpack1("H*")
12
+ end
13
+
14
+ def self.load(hexdump)
15
+ binary = [hexdump].pack("H*")
16
+ ::Marshal.load(binary)
16
17
  rescue => error
17
- $stderr.puts "#{error}: hexdump is #{hexdump.inspect} #{error.backtrace.join("\n")}"
18
+ warn "#{error}: hexdump is #{hexdump.inspect} #{error.backtrace.join("\n")}"
18
19
  Date.new
19
- end
20
- end
20
+ end
21
+ end
21
22
  end
data/lib/odba/odba.rb CHANGED
@@ -2,44 +2,52 @@
2
2
  # ODBA -- odba -- 26.01.2007 -- hwyss@ywesee.com
3
3
 
4
4
  module ODBA
5
- # reader for the Cache server. Defaults to ODBA::Cache.instance
6
- def ODBA.cache
7
- @cache ||= ODBA::Cache.instance
8
- end
9
- # writer for the Cache server. You will probably never need this.
10
- def ODBA.cache=(cache_server)
11
- @cache = cache_server
12
- end
13
- # reader for the Marshaller. Defaults to ODBA.Marshal
14
- def ODBA.marshaller
15
- @marshaller ||= ODBA::Marshal
16
- end
17
- # writer for the Marshaller. Example: override the default Marshaller to
18
- # serialize your objects in a custom format (yaml, xml, ...).
19
- def ODBA.marshaller=(marshaller)
20
- @marshaller = marshaller
21
- end
5
+ # reader for the Cache server. Defaults to ODBA::Cache.instance
6
+ def self.cache
7
+ @cache ||= ODBA::Cache.instance
8
+ end
9
+
10
+ # writer for the Cache server. You will probably never need this.
11
+ def self.cache=(cache_server)
12
+ @cache = cache_server
13
+ end
14
+
15
+ # reader for the Marshaller. Defaults to ODBA.Marshal
16
+ def self.marshaller
17
+ @marshaller ||= ODBA::Marshal
18
+ end
19
+
20
+ # writer for the Marshaller. Example: override the default Marshaller to
21
+ # serialize your objects in a custom format (yaml, xml, ...).
22
+ def self.marshaller=(marshaller)
23
+ @marshaller = marshaller
24
+ end
25
+
22
26
  # peer two instances of ODBA::Cache
23
- def ODBA.peer peer
27
+ def self.peer peer
24
28
  peer.register_peer ODBA.cache
25
29
  ODBA.cache.register_peer peer
26
30
  end
27
- # reader for the Storage Server. Defaults to ODBA::Storage.instance
28
- def ODBA.storage
29
- @storage ||= ODBA::Storage.instance
30
- end
31
- # writer for the Storage Server. Example: override the default Storage Server
32
- # to dump all your data in a flatfile.
33
- def ODBA.storage=(storage)
34
- @storage = storage
35
- end
31
+
32
+ # reader for the Storage Server. Defaults to ODBA::Storage.instance
33
+ def self.storage
34
+ @storage ||= ODBA::Storage.instance
35
+ end
36
+
37
+ # writer for the Storage Server. Example: override the default Storage Server
38
+ # to dump all your data in a flatfile.
39
+ def self.storage=(storage)
40
+ @storage = storage
41
+ end
42
+
36
43
  # unpeer two instances of ODBA::Cache
37
- def ODBA.unpeer peer
44
+ def self.unpeer peer
38
45
  peer.unregister_peer ODBA.cache
39
46
  ODBA.cache.unregister_peer peer
40
47
  end
41
- # Convenience method. Delegates the transaction-call to the Cache server.
42
- def ODBA.transaction(&block)
43
- ODBA.cache.transaction(&block)
44
- end
48
+
49
+ # Convenience method. Delegates the transaction-call to the Cache server.
50
+ def self.transaction(&block)
51
+ ODBA.cache.transaction(&block)
52
+ end
45
53
  end
@@ -2,11 +2,13 @@
2
2
  #-- OdbaError -- odba -- 29.04.2004 -- hwyss@ywesee.com rwaltert@ywesee.com mwalder@ywesee.com
3
3
 
4
4
  module ODBA
5
- class OdbaError < RuntimeError
6
- end
5
+ class OdbaError < RuntimeError
6
+ end
7
+
7
8
  class OdbaResultLimitError < OdbaError
8
9
  attr_accessor :limit, :size, :index, :search_term, :meta
9
10
  end
11
+
10
12
  class OdbaDuplicateIdError < OdbaError
11
13
  end
12
14
  end