miyazakiresistance 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -39,6 +39,8 @@ MiyazakiResistance support Dual Master(Active/Standby). If Active server down, S
39
39
  Example.find(:all, :conditions => ["name = ? age = ?", "tsukasa", 34], :order => "created_at DESC", :offset => 1, :limit => 1)
40
40
  Example.find_by_name("tsukasa")
41
41
  Example.find_all_by_name_and_age("tsukasa", 34)
42
+ Example.first
43
+ Example.delete_all(["created_at > ?", Time.local(2009,11,15)])
42
44
 
43
45
 
44
46
  * You can write in config file
@@ -109,6 +109,10 @@ module MiyazakiResistance
109
109
  list.each {|inst| yield(inst) and inst.save}
110
110
  end
111
111
 
112
+ def first(args = {})
113
+ find(:first, args)
114
+ end
115
+
112
116
  def count(args = {})
113
117
  con = read_connection
114
118
  if args.empty?
@@ -116,7 +120,21 @@ module MiyazakiResistance
116
120
  else
117
121
  query = TokyoTyrant::RDBQRY.new(con)
118
122
  query = make_conditions(query, args[:conditions])
119
- kaeru_timeout{query.search.count}
123
+ query.respond_to?(:searchcount) ? kaeru_timeout{query.searchcount} : kaeru_timeout{query.search.count}
124
+ end
125
+ rescue TimeoutError
126
+ remove_pool(con)
127
+ retry
128
+ end
129
+
130
+ def delete_all(args = [])
131
+ con = write_connection
132
+ if args.empty?
133
+ con.vanish
134
+ else
135
+ query = TokyoTyrant::RDBQRY.new(con)
136
+ query = make_conditions(query, args)
137
+ kaeru_timeout{query.searchout}
120
138
  end
121
139
  rescue TimeoutError
122
140
  remove_pool(con)
@@ -9,7 +9,7 @@ Dir.glob("#{File.join(File.dirname(__FILE__), "../initializers")}/*.rb").each{|p
9
9
  Dir.glob("#{File.join(File.dirname(__FILE__), "miyazaki_resistance")}/*.rb").each{|path| require path}
10
10
 
11
11
  module MiyazakiResistance
12
- VERSION = '0.1.4'
12
+ VERSION = '0.1.5'
13
13
  end
14
14
 
15
15
  MiyazakiResistance::Base.class_eval do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miyazakiresistance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsukasa OISHI