simple_record 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_record.rb +26 -26
- data/lib/simple_record/json.rb +3 -9
- data/lib/simple_record/results_array.rb +3 -2
- data/lib/simple_record/translations.rb +4 -4
- metadata +29 -4
data/lib/simple_record.rb
CHANGED
@@ -591,7 +591,7 @@ module SimpleRecord
|
|
591
591
|
connection.delete_attributes(domain, id)
|
592
592
|
end
|
593
593
|
|
594
|
-
def self.delete_all(*
|
594
|
+
def self.delete_all(*params)
|
595
595
|
# could make this quicker by just getting item_names and deleting attributes rather than creating objects
|
596
596
|
obs = self.find(params)
|
597
597
|
i = 0
|
@@ -602,7 +602,7 @@ module SimpleRecord
|
|
602
602
|
return i
|
603
603
|
end
|
604
604
|
|
605
|
-
def self.destroy_all(*
|
605
|
+
def self.destroy_all(*params)
|
606
606
|
obs = self.find(params)
|
607
607
|
i = 0
|
608
608
|
obs.each do |a|
|
@@ -804,7 +804,7 @@ module SimpleRecord
|
|
804
804
|
# Query example:
|
805
805
|
# MyModel.find(:all, :conditions=>["name = ?", name], :order=>"created desc", :limit=>10)
|
806
806
|
#
|
807
|
-
def self.find(*
|
807
|
+
def self.find(*params)
|
808
808
|
#puts 'params=' + params.inspect
|
809
809
|
q_type = :all
|
810
810
|
select_attributes=[]
|
@@ -825,7 +825,7 @@ module SimpleRecord
|
|
825
825
|
|
826
826
|
results = q_type == :all ? [] : nil
|
827
827
|
begin
|
828
|
-
results=super(*
|
828
|
+
results=super(*params)
|
829
829
|
# puts "RESULT=" + results.inspect
|
830
830
|
#puts 'params3=' + params.inspect
|
831
831
|
SimpleRecord.stats.selects += 1
|
@@ -848,33 +848,33 @@ module SimpleRecord
|
|
848
848
|
return results
|
849
849
|
end
|
850
850
|
|
851
|
-
def self.select(*
|
852
|
-
return find(*
|
851
|
+
def self.select(*params)
|
852
|
+
return find(*params)
|
853
853
|
end
|
854
854
|
|
855
|
-
def self.all(*
|
856
|
-
find(:all, *
|
855
|
+
def self.all(*args)
|
856
|
+
find(:all, *args)
|
857
857
|
end
|
858
858
|
|
859
|
-
def self.first(*
|
860
|
-
find(:first, *
|
859
|
+
def self.first(*args)
|
860
|
+
find(:first, *args)
|
861
861
|
end
|
862
862
|
|
863
|
-
def self.count(*
|
864
|
-
find(:count, *
|
863
|
+
def self.count(*args)
|
864
|
+
find(:count, *args)
|
865
865
|
end
|
866
866
|
|
867
867
|
# This gets less and less efficient the higher the page since SimpleDB has no way
|
868
868
|
# to start at a specific row. So it will iterate from the first record and pull out the specific pages.
|
869
869
|
def self.paginate(options={})
|
870
870
|
# options = args.pop
|
871
|
-
puts 'paginate options=' + options.inspect if SimpleRecord.logging?
|
871
|
+
# puts 'paginate options=' + options.inspect if SimpleRecord.logging?
|
872
872
|
page = options[:page] || 1
|
873
873
|
per_page = options[:per_page] || self.per_page || 50
|
874
874
|
total = options[:total_entries]
|
875
875
|
options[:limit] = page * per_page
|
876
876
|
fr = find(:all, options)
|
877
|
-
puts 'fr.size=' + fr.size.to_s
|
877
|
+
# puts 'fr.size=' + fr.size.to_s
|
878
878
|
ret = []
|
879
879
|
i = 0
|
880
880
|
p = 1
|
@@ -932,8 +932,8 @@ module SimpleRecord
|
|
932
932
|
@@debug
|
933
933
|
end
|
934
934
|
|
935
|
-
def self.sanitize_sql(*
|
936
|
-
return ActiveRecord::Base.sanitize_sql(*
|
935
|
+
def self.sanitize_sql(*params)
|
936
|
+
return ActiveRecord::Base.sanitize_sql(*params)
|
937
937
|
end
|
938
938
|
|
939
939
|
def self.table_name
|
@@ -1010,30 +1010,30 @@ module SimpleRecord
|
|
1010
1010
|
return count
|
1011
1011
|
end
|
1012
1012
|
|
1013
|
-
def each(*
|
1014
|
-
return load.each(*
|
1013
|
+
def each(*params, &block)
|
1014
|
+
return load.each(*params) { |record| block.call(record) }
|
1015
1015
|
end
|
1016
1016
|
|
1017
|
-
def find_all(*
|
1018
|
-
find(:all, *
|
1017
|
+
def find_all(*params)
|
1018
|
+
find(:all, *params)
|
1019
1019
|
end
|
1020
1020
|
|
1021
1021
|
def empty?
|
1022
1022
|
return load.empty?
|
1023
1023
|
end
|
1024
1024
|
|
1025
|
-
def build(*
|
1025
|
+
def build(*params)
|
1026
1026
|
params[0][@referencename]=@referencevalue
|
1027
|
-
eval(@subname).new(*
|
1027
|
+
eval(@subname).new(*params)
|
1028
1028
|
end
|
1029
1029
|
|
1030
|
-
def create(*
|
1030
|
+
def create(*params)
|
1031
1031
|
params[0][@referencename]=@referencevalue
|
1032
|
-
record = eval(@subname).new(*
|
1032
|
+
record = eval(@subname).new(*params)
|
1033
1033
|
record.save
|
1034
1034
|
end
|
1035
1035
|
|
1036
|
-
def find(*
|
1036
|
+
def find(*params)
|
1037
1037
|
query=[:first, {}]
|
1038
1038
|
#{:conditions=>"id=>1"}
|
1039
1039
|
if params[0]
|
@@ -1056,7 +1056,7 @@ module SimpleRecord
|
|
1056
1056
|
#query[1][:conditions]="id='#{@id}'"
|
1057
1057
|
end
|
1058
1058
|
|
1059
|
-
return eval(@subname).find(*
|
1059
|
+
return eval(@subname).find(*query)
|
1060
1060
|
end
|
1061
1061
|
|
1062
1062
|
end
|
data/lib/simple_record/json.rb
CHANGED
@@ -2,8 +2,6 @@ module SimpleRecord
|
|
2
2
|
module Json
|
3
3
|
|
4
4
|
def self.included(base)
|
5
|
-
puts "TestMixin included in #{base}"
|
6
|
-
|
7
5
|
base.extend ClassMethods
|
8
6
|
end
|
9
7
|
|
@@ -24,7 +22,7 @@ module SimpleRecord
|
|
24
22
|
|
25
23
|
end
|
26
24
|
|
27
|
-
def to_json(*
|
25
|
+
def to_json(*a)
|
28
26
|
result = {
|
29
27
|
'json_class' => self.class.name
|
30
28
|
}
|
@@ -37,12 +35,8 @@ module SimpleRecord
|
|
37
35
|
end
|
38
36
|
# puts 'result[name]=' + result[name].inspect
|
39
37
|
end
|
40
|
-
|
41
|
-
|
42
|
-
# r[name[1..-1]] = instance_variable_get name
|
43
|
-
# r
|
44
|
-
# end
|
45
|
-
result.to_json(* a)
|
38
|
+
|
39
|
+
result.to_json(*a)
|
46
40
|
end
|
47
41
|
|
48
42
|
end
|
@@ -74,8 +74,9 @@ module SimpleRecord
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def size
|
77
|
-
|
78
|
-
|
77
|
+
if @next_token.nil?
|
78
|
+
return @items.size
|
79
|
+
end
|
79
80
|
return @count if @count
|
80
81
|
params_for_count = params.dup
|
81
82
|
params_for_count[0] = :count
|
@@ -29,14 +29,14 @@ module SimpleRecord
|
|
29
29
|
unless value.blank?
|
30
30
|
if att_meta.options
|
31
31
|
if att_meta.options[:encrypted]
|
32
|
-
puts "ENCRYPTING #{name} value #{value}"
|
32
|
+
# puts "ENCRYPTING #{name} value #{value}"
|
33
33
|
ret = Translations.encrypt(ret, att_meta.options[:encrypted])
|
34
|
-
puts 'encrypted value=' + ret.to_s
|
34
|
+
# puts 'encrypted value=' + ret.to_s
|
35
35
|
end
|
36
36
|
if att_meta.options[:hashed]
|
37
|
-
puts "hashing #{name}"
|
37
|
+
# puts "hashing #{name}"
|
38
38
|
ret = Translations.pass_hash(ret)
|
39
|
-
puts "hashed value=" + ret.inspect
|
39
|
+
# puts "hashed value=" + ret.inspect
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
9
|
+
- 3
|
10
|
+
version: 1.3.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Travis Reeder
|
@@ -16,16 +17,18 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2010-05-
|
20
|
+
date: 2010-05-17 00:00:00 -07:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: aws
|
24
25
|
prerelease: false
|
25
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
26
28
|
requirements:
|
27
29
|
- - ">="
|
28
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
29
32
|
segments:
|
30
33
|
- 0
|
31
34
|
version: "0"
|
@@ -52,6 +55,24 @@ files:
|
|
52
55
|
- lib/simple_record/stats.rb
|
53
56
|
- lib/simple_record/translations.rb
|
54
57
|
- README.markdown
|
58
|
+
- test/conversions.rb
|
59
|
+
- test/model_with_enc.rb
|
60
|
+
- test/my_base_model.rb
|
61
|
+
- test/my_child_model.rb
|
62
|
+
- test/my_model.rb
|
63
|
+
- test/paging_array_test.rb
|
64
|
+
- test/temp_test.rb
|
65
|
+
- test/test_base.rb
|
66
|
+
- test/test_dirty.rb
|
67
|
+
- test/test_encodings.rb
|
68
|
+
- test/test_global_options.rb
|
69
|
+
- test/test_helpers.rb
|
70
|
+
- test/test_json.rb
|
71
|
+
- test/test_lobs.rb
|
72
|
+
- test/test_marshalled.rb
|
73
|
+
- test/test_pagination.rb
|
74
|
+
- test/test_results_array.rb
|
75
|
+
- test/test_simple_record.rb
|
55
76
|
has_rdoc: true
|
56
77
|
homepage: http://github.com/appoxy/simple_record/
|
57
78
|
licenses: []
|
@@ -62,23 +83,27 @@ rdoc_options:
|
|
62
83
|
require_paths:
|
63
84
|
- lib
|
64
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
65
87
|
requirements:
|
66
88
|
- - ">="
|
67
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
68
91
|
segments:
|
69
92
|
- 0
|
70
93
|
version: "0"
|
71
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
72
96
|
requirements:
|
73
97
|
- - ">="
|
74
98
|
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
75
100
|
segments:
|
76
101
|
- 0
|
77
102
|
version: "0"
|
78
103
|
requirements: []
|
79
104
|
|
80
105
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.3.
|
106
|
+
rubygems_version: 1.3.7
|
82
107
|
signing_key:
|
83
108
|
specification_version: 3
|
84
109
|
summary: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
|