active_hash 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG +3 -0
- data/README.md +1 -15
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/active_hash.gemspec +3 -6
- data/lib/associations/associations.rb +7 -2
- data/spec/associations/associations_spec.rb +11 -3
- metadata +6 -8
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -325,20 +325,6 @@ Constants are formed by first stripping all non-word characters and then upcasin
|
|
325
325
|
|
326
326
|
The field specified as the _enum_accessor_ must contain unique data values.
|
327
327
|
|
328
|
-
## Authors
|
329
|
-
|
330
|
-
* Jeff Dean
|
331
|
-
* Mike Dalessio
|
332
|
-
* Ben Woosley
|
333
|
-
* John Pignata
|
334
|
-
* Pat Nakajima
|
335
|
-
* Brandon Keene
|
336
|
-
* Dave Yeu
|
337
|
-
* Brian Takita
|
338
|
-
* Corey Innis
|
339
|
-
* Peter Jaros
|
340
|
-
* Michael Schubert
|
341
|
-
|
342
328
|
## Copyright
|
343
329
|
|
344
|
-
Copyright (c)
|
330
|
+
Copyright (c) 2010 Jeff Dean. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -21,9 +21,10 @@ begin
|
|
21
21
|
"Jeremy Weiskotten",
|
22
22
|
"Ryan Garver",
|
23
23
|
"Tom Stuart",
|
24
|
+
"Joel Chippindale"
|
24
25
|
]
|
25
26
|
gem.add_dependency('activesupport', [">= 2.2.2"])
|
26
|
-
gem.post_install_message = "
|
27
|
+
# gem.post_install_message = ""
|
27
28
|
end
|
28
29
|
Jeweler::GemcutterTasks.new
|
29
30
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.6
|
data/active_hash.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active_hash}
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.6"
|
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", "Brandon Keene", "Brian Takita", "Pat Nakajima", "John Pignata", "Michael Schubert", "Jeremy Weiskotten", "Ryan Garver", "Tom Stuart"]
|
12
|
-
s.date = %q{2010-
|
11
|
+
s.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros", "Brandon Keene", "Brian Takita", "Pat Nakajima", "John Pignata", "Michael Schubert", "Jeremy Weiskotten", "Ryan Garver", "Tom Stuart", "Joel Chippindale"]
|
12
|
+
s.date = %q{2010-11-07}
|
13
13
|
s.email = %q{jeff@zilkey.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -45,9 +45,6 @@ Gem::Specification.new do |s|
|
|
45
45
|
"spec/spec_helper.rb"
|
46
46
|
]
|
47
47
|
s.homepage = %q{http://github.com/zilkey/active_hash}
|
48
|
-
s.post_install_message = %q{NOTE: Enums have changed to use underscores.
|
49
|
-
|
50
|
-
You may have to do a search and replace to get your suite green.}
|
51
48
|
s.rdoc_options = ["--charset=UTF-8"]
|
52
49
|
s.require_paths = ["lib"]
|
53
50
|
s.rubygems_version = %q{1.3.7}
|
@@ -14,9 +14,14 @@ module ActiveHash
|
|
14
14
|
:foreign_key => self.class.to_s.foreign_key
|
15
15
|
}.merge(options)
|
16
16
|
|
17
|
-
options[:class_name].constantize
|
18
|
-
end
|
17
|
+
klass = options[:class_name].constantize
|
19
18
|
|
19
|
+
if klass.respond_to?(:scoped)
|
20
|
+
klass.scoped(:conditions => { options[:foreign_key] => id })
|
21
|
+
else
|
22
|
+
klass.send("find_all_by_#{options[:foreign_key]}", id)
|
23
|
+
end
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def belongs_to(association_id, options = {})
|
@@ -27,7 +27,9 @@ describe ActiveHash::Base, "associations" do
|
|
27
27
|
establish_connection :adapter => "sqlite3", :database => ":memory:"
|
28
28
|
connection.create_table(:books, :force => true) do |t|
|
29
29
|
t.integer :author_id
|
30
|
+
t.boolean :published
|
30
31
|
end
|
32
|
+
named_scope :published, { :conditions => { :published => true } }
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -43,9 +45,9 @@ describe ActiveHash::Base, "associations" do
|
|
43
45
|
|
44
46
|
context "with ActiveRecord children" do
|
45
47
|
before do
|
46
|
-
@included_book_1 = Book.create! :author_id => 1
|
47
|
-
@included_book_2 = Book.create! :author_id => 1
|
48
|
-
@excluded_book = Book.create! :author_id => 2
|
48
|
+
@included_book_1 = Book.create! :author_id => 1, :published => true
|
49
|
+
@included_book_2 = Book.create! :author_id => 1, :published => false
|
50
|
+
@excluded_book = Book.create! :author_id => 2, :published => true
|
49
51
|
end
|
50
52
|
|
51
53
|
it "find the correct records" do
|
@@ -53,6 +55,12 @@ describe ActiveHash::Base, "associations" do
|
|
53
55
|
author = Author.create :id => 1
|
54
56
|
author.books.should =~ [@included_book_1, @included_book_2]
|
55
57
|
end
|
58
|
+
|
59
|
+
it "return a scope so that we can apply further scopes" do
|
60
|
+
Author.has_many :books
|
61
|
+
author = Author.create :id => 1
|
62
|
+
author.books.published.should =~ [@included_book_1]
|
63
|
+
end
|
56
64
|
end
|
57
65
|
|
58
66
|
context "with ActiveHash children" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 6
|
10
|
+
version: 0.8.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeff Dean
|
@@ -22,11 +22,12 @@ authors:
|
|
22
22
|
- Jeremy Weiskotten
|
23
23
|
- Ryan Garver
|
24
24
|
- Tom Stuart
|
25
|
+
- Joel Chippindale
|
25
26
|
autorequire:
|
26
27
|
bindir: bin
|
27
28
|
cert_chain: []
|
28
29
|
|
29
|
-
date: 2010-
|
30
|
+
date: 2010-11-07 00:00:00 -06:00
|
30
31
|
default_executable:
|
31
32
|
dependencies:
|
32
33
|
- !ruby/object:Gem::Dependency
|
@@ -86,10 +87,7 @@ has_rdoc: true
|
|
86
87
|
homepage: http://github.com/zilkey/active_hash
|
87
88
|
licenses: []
|
88
89
|
|
89
|
-
post_install_message:
|
90
|
-
NOTE: Enums have changed to use underscores.
|
91
|
-
|
92
|
-
You may have to do a search and replace to get your suite green.
|
90
|
+
post_install_message:
|
93
91
|
rdoc_options:
|
94
92
|
- --charset=UTF-8
|
95
93
|
require_paths:
|