christiank-turntable 0.5 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/turntable.rb +11 -1
  2. metadata +1 -1
data/turntable.rb CHANGED
@@ -36,7 +36,7 @@ class Turntable < PStore
36
36
 
37
37
  # Reader methods for this database's metadata.
38
38
  attr_reader :filename, :columns
39
- def version; @@version; end
39
+ def Turntable.version; @@version; end
40
40
 
41
41
  # This hack should eliminate the need for transactions
42
42
  #def in_transaction; true; end
@@ -57,6 +57,11 @@ class Turntable < PStore
57
57
  end
58
58
  alias :select_all :all
59
59
 
60
+ # Removes the specified row from the table.
61
+ def delete id
62
+ self.transaction { @table.delete id }
63
+ end
64
+
60
65
  # Pushes self with a new row.
61
66
  # Columns named :id are autoincrement fields.
62
67
  def insert *args
@@ -73,6 +78,8 @@ class Turntable < PStore
73
78
 
74
79
  return row
75
80
  end
81
+
82
+ def inspect; self.to_s; end
76
83
 
77
84
  # The select statement. Equivalent to self.all.select() if there's a block,
78
85
  # otherwise just return the specified row. In a perfect world, we should be
@@ -128,5 +135,8 @@ class Row < OpenStruct
128
135
 
129
136
  end
130
137
 
138
+ # Turntable prefers contains?() instead of include?()
139
+ class Array; alias :contains? :include?; end
140
+
131
141
  # Quick hack to shut up Object#id deprecation warnings
132
142
  class Object; undef id; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: christiank-turntable
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.5"
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Koch