dovadi-has_attributes_from 0.1.2 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -2
- data/Manifest.txt +2 -0
- data/README.textile +49 -60
- data/tasks/has_attributes_from.rake +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
=== 0.
|
1
|
+
=== 0.1.4 2009-08-24
|
2
2
|
|
3
|
-
*
|
3
|
+
* Created a log folder, to prevent a failing build of the gem on Github
|
4
|
+
|
5
|
+
=== 0.1.3 2009-08-24
|
6
|
+
|
7
|
+
* Added init.rb so has_attribute_from can be installed as a plugin
|
4
8
|
|
5
9
|
=== 0.1.2 2009-08-21
|
6
10
|
|
7
11
|
* Rename gem to 'has_attributes_from' and some cleanup of the code
|
12
|
+
|
13
|
+
=== 0.0.1 2009-08-20
|
14
|
+
|
15
|
+
* Initial release
|
data/Manifest.txt
CHANGED
@@ -2,6 +2,7 @@ History.txt
|
|
2
2
|
Manifest.txt
|
3
3
|
README.textile
|
4
4
|
Rakefile
|
5
|
+
init.rb
|
5
6
|
lib/has_attributes_from/base.rb
|
6
7
|
lib/has_attributes_from.rb
|
7
8
|
tasks/has_attributes_from.rake
|
@@ -22,6 +23,7 @@ test/rails_root/db/migrate/20090820105521_create_employee_properties.rb
|
|
22
23
|
test/rails_root/db/migrate/20090820110621_create_customer_details.rb
|
23
24
|
test/rails_root/db/schema.rb
|
24
25
|
test/rails_root/db/test.sqlite3
|
26
|
+
test/rails_root/log/
|
25
27
|
test/test_helper.rb
|
26
28
|
test/unit/customer_detail_test.rb
|
27
29
|
test/unit/customer_test.rb
|
data/README.textile
CHANGED
@@ -1,85 +1,74 @@
|
|
1
1
|
h2. Has_attributes_from
|
2
2
|
|
3
|
-
Download: http://github.com/dovadi/has_attributes_from
|
3
|
+
Download: http://github.com/dovadi/has_attributes_from or clone
|
4
|
+
|
5
|
+
* git clone git://github.com/dovadi/has_attributes_from.git
|
4
6
|
|
5
7
|
h2. Description:
|
6
8
|
|
7
9
|
Merge the attributes from another ActiveRecord class to an individual STI subclass.
|
8
10
|
|
9
|
-
h2.
|
10
|
-
|
11
|
-
h4. Setup
|
12
|
-
<pre>
|
13
|
-
create_table "child_details", :force => true do |t|
|
14
|
-
t.string "nickname"
|
15
|
-
t.string "allergy"
|
16
|
-
t.integer "client_id"
|
17
|
-
end
|
18
|
-
</pre>
|
19
|
-
<pre>
|
20
|
-
create_table "caretaker_details", :force => true do |t|
|
21
|
-
t.string "relation"
|
22
|
-
t.integer "caretaker_id"
|
23
|
-
end
|
24
|
-
</pre>
|
25
|
-
<pre>
|
26
|
-
create_table "people", :force => true do |t|
|
27
|
-
t.string "type"
|
28
|
-
t.string "firstname"
|
29
|
-
t.string "lastname"
|
30
|
-
t.string "email"
|
31
|
-
end
|
32
|
-
</pre>
|
11
|
+
h2. Example:
|
33
12
|
|
34
|
-
h4. Example
|
35
|
-
<pre>
|
36
|
-
class Person < ActiveRecord::Base
|
37
|
-
end
|
38
|
-
</pre>
|
39
|
-
<pre>
|
40
|
-
class Child < Person
|
41
|
-
has_attributes_from :child_details
|
42
|
-
validates_presence_of :nickname
|
43
|
-
end
|
44
|
-
</pre>
|
45
|
-
<pre>
|
46
|
-
class Caretaker < Person
|
47
|
-
has_attributes_from :caretaker_details
|
48
|
-
end
|
49
|
-
</pre>
|
50
|
-
<pre>
|
51
|
-
child = Child.create(:firstname =>'William', :lastname=>'Gates' :email=>'bgates@microsoft.com', :nickname=>'Bill')
|
52
|
-
child.update_attributes(:allergy=>'Not allowed to eat apples!')
|
53
|
-
</pre>
|
54
13
|
<pre>
|
55
|
-
|
56
|
-
|
14
|
+
create_table "child_details", :force => true do |t|
|
15
|
+
t.string "nickname"
|
16
|
+
t.string "allergy"
|
17
|
+
t.integer "client_id"
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table "caretaker_details", :force => true do |t|
|
21
|
+
t.string "relation"
|
22
|
+
t.integer "caretaker_id"
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table "people", :force => true do |t|
|
26
|
+
t.string "type"
|
27
|
+
t.string "firstname"
|
28
|
+
t.string "lastname"
|
29
|
+
t.string "email"
|
30
|
+
end
|
31
|
+
|
32
|
+
class Person < ActiveRecord::Base
|
33
|
+
end
|
34
|
+
|
35
|
+
class Child < Person
|
36
|
+
has_attributes_from :child_details
|
37
|
+
validates_presence_of :nickname
|
38
|
+
end
|
39
|
+
|
40
|
+
class Caretaker < Person
|
41
|
+
has_attributes_from :caretaker_details
|
42
|
+
end
|
43
|
+
|
44
|
+
child = Child.create(:firstname =>'William', :lastname=>'Gates' :email=>'bgates@microsoft.com', :nickname=>'Bill')
|
45
|
+
child.update_attributes(:allergy=>'Not allowed to eat apples!')
|
46
|
+
|
47
|
+
caretaker = Caretaker.create(:firstname =>'William H.', :lastname=>'Gates' :email=>'w.h.gates@gmail.com')
|
48
|
+
caretaker.update_attribute(:relation, 'Daddy')
|
57
49
|
</pre>
|
58
50
|
|
59
51
|
h2. Install:
|
60
52
|
|
61
53
|
<pre>
|
62
|
-
|
63
|
-
</pre>
|
54
|
+
As a gem:
|
64
55
|
|
65
|
-
<pre>
|
66
56
|
* sudo gem install dovadi-has_attributes_from -s http://gems.github.com or
|
67
|
-
</pre>
|
68
|
-
|
69
|
-
<pre>
|
70
57
|
* Add the following to your environment.rb:
|
71
|
-
</pre>
|
72
58
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
59
|
+
config.gem 'dovadi-has_attributes_from',
|
60
|
+
:lib => 'has_attributes_from',
|
61
|
+
:version => '>=0.1.1',
|
62
|
+
:source => 'http://gems.github.com'
|
63
|
+
|
64
|
+
As a plugin:
|
65
|
+
|
66
|
+
* ./script/plugin install git://github.com/dovadi/has_attributes_from.git
|
78
67
|
</pre>
|
79
68
|
|
80
69
|
h2. Test
|
81
70
|
|
82
|
-
* You can run the tests from this gem
|
71
|
+
* You can run the tests from this gem with rake test:default (you need to install the Shoulda and Factory_girl gems).
|
83
72
|
|
84
73
|
h2. Credits
|
85
74
|
|
@@ -15,7 +15,7 @@ task :default => ['test:has_attributes_from']
|
|
15
15
|
namespace :has_attributes_from do
|
16
16
|
gem_spec = Gem::Specification.new do |gem_spec|
|
17
17
|
gem_spec.name = "has_attributes_from"
|
18
|
-
gem_spec.version = "0.1.
|
18
|
+
gem_spec.version = "0.1.5"
|
19
19
|
gem_spec.summary = "Merge the attributes from another ActiveRecord class to an individual STI subclass."
|
20
20
|
gem_spec.email = "frank.oxener@dovadi.com"
|
21
21
|
gem_spec.homepage = "http://github.com/dovadi/has_attributes_from"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dovadi-has_attributes_from
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Oxener
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-23 15:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|