simple_record 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/simple_record.rb CHANGED
@@ -32,7 +32,6 @@ require File.expand_path(File.dirname(__FILE__) + "/simple_record/attributes")
32
32
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/active_sdb")
33
33
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/callbacks")
34
34
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/encryptor")
35
- require File.expand_path(File.dirname(__FILE__) + "/simple_record/exceptions")
36
35
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/errors")
37
36
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/json")
38
37
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/logging")
@@ -602,7 +601,12 @@ module SimpleRecord
602
601
  end
603
602
 
604
603
  def save!(options={})
605
- save(options) || raise(RecordNotSaved)
604
+ save(options) || raise(RecordNotSaved.new(nil, self))
605
+ end
606
+
607
+ # this is a bit wonky, save! should call this, not sure why it's here.
608
+ def save_with_validation!(options={})
609
+ save!
606
610
  end
607
611
 
608
612
  def self.create(attributes={})
@@ -616,14 +620,6 @@ module SimpleRecord
616
620
  item
617
621
  end
618
622
 
619
- def save_with_validation!(options={})
620
- if valid?
621
- save
622
- else
623
- raise RecordInvalid.new(self)
624
- end
625
- end
626
-
627
623
 
628
624
  def self.get_encryption_key()
629
625
  key = SimpleRecord.options[:encryption_key]
@@ -1,18 +1,22 @@
1
1
  module SimpleRecord
2
2
 
3
3
  class SimpleRecordError < StandardError
4
-
4
+
5
5
  end
6
6
 
7
7
 
8
- class RecordInvalid < SimpleRecordError
8
+ class RecordNotSaved < SimpleRecordError
9
9
  attr_accessor :record
10
10
 
11
- def initialize(record)
11
+ def initialize(record=nil)
12
12
  @record = record
13
+ super("Validation failed: #{@record.errors.full_messages.join(", ")}")
13
14
  end
14
15
  end
15
16
 
17
+ class RecordNotFound < SimpleRecordError
18
+
19
+ end
16
20
 
17
21
  class Error
18
22
  attr_accessor :base, :attribute, :type, :message, :options
data/test/temp.rb CHANGED
@@ -1,46 +1,9 @@
1
1
  require_relative 'my_model'
2
2
 
3
- class ToSClass
4
- def to_s
5
- "#{self.class.name} to_s called"
6
- end
7
- end
8
- class InspectClass
9
- def inspect
10
- "#{self.class.name} inspect called"
11
- end
12
- end
13
- class BothClass
14
- def inspect
15
- "#{self.class.name} inspect called"
16
- end
17
- def to_s
18
- "#{self.class.name} to_s called"
19
- end
20
- end
21
-
22
- c1 = ToSClass.new
23
- puts c1.inspect
24
- puts c1.to_s
25
- c1 = InspectClass.new
26
- puts c1.inspect
27
- puts c1.to_s
28
- c1 = BothClass.new
29
- puts c1.inspect
30
- puts c1.to_s
31
3
 
32
- a = []
33
- afirst = a.first
34
- puts 'afirst=' + afirst.inspect
35
-
36
- p = nil
37
- puts 'p=' + p.inspect.to_s
38
- puts "p=" + p.inspect
39
-
40
- p = MyModel.new
41
- puts 'p=' + p.inspect.to_s
42
- puts 'p=' + p.to_s
43
- puts "p=" + p.inspect
44
-
45
- id = 123
46
- puts 'id&&id ' + (id && id.to_s).inspect
4
+ begin
5
+ raise StandardError
6
+ rescue => ex
7
+ p ex
8
+ puts ex.message
9
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 0
8
- - 4
9
- version: 2.0.4
8
+ - 5
9
+ version: 2.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-28 00:00:00 -08:00
19
+ date: 2011-01-05 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: "0"
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
- description: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
35
+ description: ActiveRecord like interface for Amazon SimpleDB. Store, query, shard, etc. By http://www.appoxy.com
36
36
  email: travis@appoxy.com
37
37
  executables: []
38
38
 
@@ -47,7 +47,6 @@ files:
47
47
  - lib/simple_record/callbacks.rb
48
48
  - lib/simple_record/encryptor.rb
49
49
  - lib/simple_record/errors.rb
50
- - lib/simple_record/exceptions.rb
51
50
  - lib/simple_record/json.rb
52
51
  - lib/simple_record/logging.rb
53
52
  - lib/simple_record/password.rb
@@ -111,7 +110,7 @@ rubyforge_project:
111
110
  rubygems_version: 1.3.7
112
111
  signing_key:
113
112
  specification_version: 3
114
- summary: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
113
+ summary: ActiveRecord like interface for Amazon SimpleDB. By http://www.appoxy.com
115
114
  test_files:
116
115
  - test/conversions_test.rb
117
116
  - test/model_with_enc.rb
@@ -1,6 +0,0 @@
1
- module SimpleRecord
2
-
3
- class RecordNotSaved < StandardError
4
-
5
- end
6
- end