active_hash 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,7 @@
1
1
  2009-12-01
2
2
  - Add marked_for_destruction? to be compatible with nested attributes (Brandon Keene)
3
3
  - Added second parameter to respond_to? and cleaned up specs (Brian Takita)
4
+ - Find with an id that does not exist now raises a RecordNotFound exception to mimic ActiveRecord (Pat Nakajima)
4
5
 
5
6
  2009-10-22
6
7
  - added setters to ActiveHash::Base for all fields
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  gem.summary = %Q{An ActiveRecord-like model that uses a hash or file as a datasource}
9
9
  gem.email = "jeff@zilkey.com"
10
10
  gem.homepage = "http://github.com/zilkey/active_hash"
11
- gem.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros"]
11
+ gem.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros", "Brandon Keene", "Brian Takita", "Pat Nakajima"]
12
12
  gem.add_dependency('activesupport', [">= 2.2.2"])
13
13
  end
14
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.4
1
+ 0.7.5
data/active_hash.gemspec CHANGED
@@ -5,10 +5,10 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_hash}
8
- s.version = "0.7.4"
8
+ s.version = "0.7.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros"]
11
+ s.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros", "Brandon Keene", "Brian Takita", "Pat Nakajima"]
12
12
  s.date = %q{2009-12-01}
13
13
  s.email = %q{jeff@zilkey.com}
14
14
  s.extra_rdoc_files = [
@@ -1,4 +1,8 @@
1
1
  module ActiveHash
2
+
3
+ class RecordNotFound < StandardError
4
+ end
5
+
2
6
  class Base
3
7
  class_inheritable_accessor :data
4
8
  class << self
@@ -67,7 +71,9 @@ module ActiveHash
67
71
  when Array
68
72
  all.select {|record| id.map(&:to_i).include?(record.id) }
69
73
  else
70
- find_by_id(id)
74
+ find_by_id(id) || begin
75
+ raise RecordNotFound.new("Couldn't find #{name} with ID=#{id}")
76
+ end
71
77
  end
72
78
  end
73
79
 
@@ -160,6 +160,12 @@ describe ActiveHash, "Base" do
160
160
  it "finds the record with the specified id as a string" do
161
161
  Country.find("2").id.should == 2
162
162
  end
163
+
164
+ it "raises ActiveHash::RecordNotFound when id not found" do
165
+ proc do
166
+ Country.find(0)
167
+ end.should raise_error(ActiveHash::RecordNotFound, /Couldn't find Country with ID=0/)
168
+ end
163
169
  end
164
170
 
165
171
  context "with :all" do
metadata CHANGED
@@ -1,13 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dean
8
8
  - Mike Dalessio
9
9
  - Corey Innis
10
10
  - Peter Jaros
11
+ - Brandon Keene
12
+ - Brian Takita
13
+ - Pat Nakajima
11
14
  autorequire:
12
15
  bindir: bin
13
16
  cert_chain: []