classy-inheritance 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +2 -0
- data/config/hoe.rb +4 -2
- data/lib/classy-inheritance.rb +4 -4
- data/lib/classy-inheritance/version.rb +1 -1
- data/script/txt2html +1 -1
- data/website/index.html +52 -64
- data/website/index.txt +40 -60
- data/website/template.html.erb +10 -3
- metadata +2 -2
data/History.txt
CHANGED
data/config/hoe.rb
CHANGED
@@ -67,7 +67,9 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
67
67
|
end
|
68
68
|
|
69
69
|
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
70
|
-
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
70
|
+
#PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
71
|
+
PATH = RUBYFORGE_PROJECT
|
71
72
|
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
72
|
-
|
73
|
+
#$hoe.rsync_args = '-av --delete --ignore-errors'
|
74
|
+
$hoe.rsync_args = '-av --delete'
|
73
75
|
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
data/lib/classy-inheritance.rb
CHANGED
@@ -32,7 +32,8 @@ module Stonean
|
|
32
32
|
# Before save functionality to create/update the requisite object
|
33
33
|
define_save_method(model_sym, options[:as])
|
34
34
|
|
35
|
-
|
35
|
+
# Adds a find_with_<model_sym> class method
|
36
|
+
define_find_with_method(model_sym)
|
36
37
|
|
37
38
|
|
38
39
|
options[:attrs].each{|attr| define_accessors(model_sym, attr)}
|
@@ -61,7 +62,7 @@ module Stonean
|
|
61
62
|
before_save "save_requisite_#{model_sym}".to_sym
|
62
63
|
end
|
63
64
|
|
64
|
-
def
|
65
|
+
def define_find_with_method(model_sym)
|
65
66
|
self.class.send :define_method, "find_with_#{model_sym}" do |*args|
|
66
67
|
eval <<-CODE
|
67
68
|
if args[1] && args[1].is_a?(Hash)
|
@@ -70,7 +71,7 @@ module Stonean
|
|
70
71
|
new_val = inc_val.is_a?(Array) ? inc_val.push(:#{:model_sym}) : [inc_val, :#{model_sym}]
|
71
72
|
args[1][:include] = new_val
|
72
73
|
else
|
73
|
-
args[1].merge({:include => :#{model_sym}})
|
74
|
+
args[1].merge!({:include => :#{model_sym}})
|
74
75
|
end
|
75
76
|
else
|
76
77
|
args << {:include => :#{model_sym}}
|
@@ -101,7 +102,6 @@ module Stonean
|
|
101
102
|
{ :foreign_key => "#{polymorphic_name}_id",
|
102
103
|
:conditions => "#{polymorphic_name}_type = '#{self.name}'"}
|
103
104
|
end
|
104
|
-
|
105
105
|
end # ClassMethods
|
106
106
|
end # ClassyInheritance module
|
107
107
|
end # Stonean module
|
data/script/txt2html
CHANGED
data/website/index.html
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
7
|
<title>
|
8
|
-
|
8
|
+
Classy Inheritance
|
9
9
|
</title>
|
10
10
|
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
11
|
<style>
|
@@ -30,112 +30,100 @@
|
|
30
30
|
<body>
|
31
31
|
<div id="main">
|
32
32
|
|
33
|
-
<h1>
|
34
|
-
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/
|
33
|
+
<h1>Classy Inheritance</h1>
|
34
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/classyinherit"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/
|
36
|
+
<a href="http://rubyforge.org/projects/classyinherit" class="numbers">0.1.1</a>
|
37
37
|
</div>
|
38
|
-
<
|
38
|
+
<p><i>“You stay classy, inheritance” – Gibson</i></p>
|
39
39
|
|
40
40
|
|
41
41
|
<h2>What</h2>
|
42
42
|
|
43
43
|
|
44
|
-
<
|
45
|
-
|
46
|
-
|
47
|
-
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">classy</span><span class="punct">-</span><span class="ident">inheritance</span></pre></p>
|
48
|
-
|
49
|
-
|
50
|
-
<h2>The basics</h2>
|
51
|
-
|
52
|
-
|
53
|
-
<h2>Demonstration of usage</h2>
|
54
|
-
|
55
|
-
|
56
|
-
<h2>Forum</h2>
|
57
|
-
|
58
|
-
|
59
|
-
<p><a href="http://groups.google.com/group/classy-inheritance">http://groups.google.com/group/classy-inheritance</a></p>
|
60
|
-
|
61
|
-
|
62
|
-
<p><span class="caps">TODO</span> – create Google Group – classy-inheritance</p>
|
63
|
-
|
44
|
+
<p>For now, Classy Inheritance adds a depends_on class method to your ActiveRecord model so that you can define requisite objects.
|
45
|
+
More functionality coming for optional relationships.</p>
|
64
46
|
|
65
|
-
<h2>How to submit patches</h2>
|
66
|
-
|
67
|
-
|
68
|
-
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
69
47
|
|
48
|
+
You can define the relationship to be polymorphic:
|
49
|
+
<pre>
|
50
|
+
class Picture < ActiveRecord::Base
|
51
|
+
depends_on :image, :attrs => [:filename, :height, :width], :as => "imageable"
|
52
|
+
end
|
53
|
+
</pre>
|
70
54
|
|
71
|
-
<p
|
55
|
+
<p>This will look for “imageable_type” and “imageable_id” on the images table add set them accordingly.</p>
|
72
56
|
|
73
57
|
|
74
|
-
|
58
|
+
Or you can define a standard belongs_to relationship:
|
59
|
+
<pre>
|
60
|
+
class User < ActiveRecord::Base
|
61
|
+
depends_on :profile, :attrs => [:first_name, :last_name, :email]
|
62
|
+
end
|
63
|
+
</pre>
|
75
64
|
|
65
|
+
<h3>What does it do for me?</h3>
|
76
66
|
|
77
|
-
<p><span class="caps">OOOORRRR</span></p>
|
78
67
|
|
68
|
+
<p>Well, for starters you get pass-through methods added to your model. So, in the above User example you would get the following:</p>
|
79
69
|
|
80
|
-
<p>You can fetch the source from either:</p>
|
81
70
|
|
71
|
+
<pre>
|
72
|
+
@user.first_name
|
73
|
+
@user.last_name
|
74
|
+
@user.email
|
75
|
+
@user.first_name=
|
76
|
+
@user.last_name=
|
77
|
+
@user.email=
|
78
|
+
</pre>
|
82
79
|
|
83
|
-
<
|
84
|
-
<li>rubyforge: <span class="caps">MISSING IN ACTION</span></li>
|
85
|
-
</ul>
|
80
|
+
<p>This means you can use these attributes on your form and in your controller instead of having to worry about creating/updating a separate Profile model.</p>
|
86
81
|
|
87
82
|
|
88
|
-
<p
|
89
|
-
yet to refresh your local rubyforge data with this projects’ id information.</p>
|
83
|
+
<p>For the above example, you’ll also get a “find_with_profile” class method that will do the :include => :profile addition to your find call for you.</p>
|
90
84
|
|
91
85
|
|
92
|
-
<
|
93
|
-
|
94
|
-
|
95
|
-
<p>Or you can hack website/index.txt and make it all go away!!</p>
|
86
|
+
<h2>Installing</h2>
|
96
87
|
|
97
88
|
|
98
|
-
|
99
|
-
|
100
|
-
</ul>
|
89
|
+
<pre>
|
90
|
+
$ sudo gem install classy-inheritance
|
101
91
|
|
92
|
+
# in environment.rb add:
|
93
|
+
require "classy-inheritance"
|
102
94
|
|
103
|
-
|
95
|
+
</pre>
|
104
96
|
|
105
|
-
<
|
97
|
+
<h2>How to submit patches</h2>
|
106
98
|
|
107
99
|
|
108
|
-
<
|
109
|
-
<li>gitorious: <a href="git://gitorious.org/classy-inheritance/mainline.git">git://gitorious.org/classy-inheritance/mainline.git</a></li>
|
110
|
-
</ul>
|
100
|
+
<p>The Clone <span class="caps">URL</span>: git://github.com/stonean/classy-inheritance.git</p>
|
111
101
|
|
112
102
|
|
113
|
-
<
|
103
|
+
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
114
104
|
|
115
|
-
<h3>Build and test instructions</h3>
|
116
105
|
|
106
|
+
<p>I’m new to git and this whole opensource project admin gig, so please be patient with my stumbling around.</p>
|
117
107
|
|
118
|
-
<pre>cd classy-inheritance
|
119
|
-
rake test
|
120
|
-
rake install_gem</pre>
|
121
108
|
|
122
109
|
<h2>License</h2>
|
123
110
|
|
124
111
|
|
125
112
|
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
126
|
-
|
127
|
-
|
128
|
-
<h2>Contact</h2>
|
129
|
-
|
130
|
-
|
131
|
-
<p>Comments are welcome. Send an email to <a href="mailto:FIXME"><span class="caps">FIXME</span> full name</a> email via the <a href="http://groups.google.com/group/classy-inheritance">forum</a></p>
|
132
113
|
<p class="coda">
|
133
|
-
<a href="
|
114
|
+
<a href="http://blog.stonean.com">Andrew Stone</a>, 29th May 2008<br>
|
134
115
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
135
116
|
</p>
|
136
117
|
</div>
|
137
|
-
|
138
|
-
|
118
|
+
<script type="text/javascript">
|
119
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
120
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
121
|
+
</script>
|
122
|
+
<script type="text/javascript">
|
123
|
+
var pageTracker = _gat._getTracker("UA-4555592-1");
|
124
|
+
pageTracker._initData();
|
125
|
+
pageTracker._trackPageview();
|
126
|
+
</script>
|
139
127
|
|
140
128
|
</body>
|
141
129
|
</html>
|
data/website/index.txt
CHANGED
@@ -1,83 +1,63 @@
|
|
1
|
-
h1.
|
2
|
-
|
3
|
-
h1. → 'classy-inheritance'
|
1
|
+
h1. <a href="http://lockdown.rubyforge.org">Classy Inheritance</a>
|
4
2
|
|
3
|
+
<i>"You stay classy, inheritance" - Gibson</i>
|
5
4
|
|
6
5
|
h2. What
|
7
6
|
|
7
|
+
For now, Classy Inheritance adds a depends_on class method to your ActiveRecord model so that you can define requisite objects.
|
8
|
+
More functionality coming for optional relationships.
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
h2. Demonstration of usage
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
h2. Forum
|
21
|
-
|
22
|
-
"http://groups.google.com/group/classy-inheritance":http://groups.google.com/group/classy-inheritance
|
23
|
-
|
24
|
-
TODO - create Google Group - classy-inheritance
|
25
|
-
|
26
|
-
h2. How to submit patches
|
27
|
-
|
28
|
-
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
10
|
+
You can define the relationship to be polymorphic:
|
11
|
+
<pre>
|
12
|
+
class Picture < ActiveRecord::Base
|
13
|
+
depends_on :image, :attrs => [:filename, :height, :width], :as => "imageable"
|
14
|
+
end
|
15
|
+
</pre>
|
29
16
|
|
30
|
-
|
17
|
+
This will look for "imageable_type" and "imageable_id" on the images table add set them accordingly.
|
31
18
|
|
32
|
-
|
19
|
+
Or you can define a standard belongs_to relationship:
|
20
|
+
<pre>
|
21
|
+
class User < ActiveRecord::Base
|
22
|
+
depends_on :profile, :attrs => [:first_name, :last_name, :email]
|
23
|
+
end
|
24
|
+
</pre>
|
33
25
|
|
34
|
-
|
26
|
+
h3. What does it do for me?
|
35
27
|
|
36
|
-
|
28
|
+
Well, for starters you get pass-through methods added to your model. So, in the above User example you would get the following:
|
37
29
|
|
38
|
-
|
30
|
+
<pre>
|
31
|
+
@user.first_name
|
32
|
+
@user.last_name
|
33
|
+
@user.email
|
34
|
+
@user.first_name=
|
35
|
+
@user.last_name=
|
36
|
+
@user.email=
|
37
|
+
</pre>
|
39
38
|
|
40
|
-
|
39
|
+
This means you can use these attributes on your form and in your controller instead of having to worry about creating/updating a separate Profile model.
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
<% else %>
|
45
|
-
|
46
|
-
* rubyforge: MISSING IN ACTION
|
47
|
-
|
48
|
-
TODO - You can not created a RubyForge project, OR have not run <code>rubyforge config</code>
|
49
|
-
yet to refresh your local rubyforge data with this projects' id information.
|
50
|
-
|
51
|
-
When you do this, this message will magically disappear!
|
52
|
-
|
53
|
-
Or you can hack website/index.txt and make it all go away!!
|
54
|
-
|
55
|
-
<% end %>
|
56
|
-
|
57
|
-
* github: "http://github.com/GITHUB_USERNAME/classy-inheritance/tree/master":http://github.com/GITHUB_USERNAME/classy-inheritance/tree/master
|
58
|
-
|
59
|
-
<pre>git clone git://github.com/GITHUB_USERNAME/classy-inheritance.git</pre>
|
41
|
+
For the above example, you'll also get a "find_with_profile" class method that will do the :include => :profile addition to your find call for you.
|
60
42
|
|
43
|
+
h2. Installing
|
61
44
|
|
62
|
-
|
45
|
+
<pre>
|
46
|
+
$ sudo gem install classy-inheritance
|
63
47
|
|
48
|
+
# in environment.rb add:
|
49
|
+
require "classy-inheritance"
|
64
50
|
|
65
|
-
|
51
|
+
</pre>
|
66
52
|
|
67
|
-
|
53
|
+
h2. How to submit patches
|
68
54
|
|
69
|
-
|
55
|
+
The Clone URL: git://github.com/stonean/classy-inheritance.git
|
70
56
|
|
71
|
-
|
72
|
-
rake test
|
73
|
-
rake install_gem</pre>
|
57
|
+
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
74
58
|
|
59
|
+
I'm new to git and this whole opensource project admin gig, so please be patient with my stumbling around.
|
75
60
|
|
76
61
|
h2. License
|
77
62
|
|
78
|
-
This code is free to use under the terms of the MIT license.
|
79
|
-
|
80
|
-
h2. Contact
|
81
|
-
|
82
|
-
Comments are welcome. Send an email to "FIXME full name":mailto:FIXME email via the "forum":http://groups.google.com/group/classy-inheritance
|
83
|
-
|
63
|
+
This code is free to use under the terms of the MIT license.
|
data/website/template.html.erb
CHANGED
@@ -37,12 +37,19 @@
|
|
37
37
|
</div>
|
38
38
|
<%= body %>
|
39
39
|
<p class="coda">
|
40
|
-
<a href="
|
40
|
+
<a href="http://blog.stonean.com">Andrew Stone</a>, <%= modified.pretty %><br>
|
41
41
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
42
42
|
</p>
|
43
43
|
</div>
|
44
|
-
|
45
|
-
|
44
|
+
<script type="text/javascript">
|
45
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
46
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
47
|
+
</script>
|
48
|
+
<script type="text/javascript">
|
49
|
+
var pageTracker = _gat._getTracker("UA-4555592-1");
|
50
|
+
pageTracker._initData();
|
51
|
+
pageTracker._trackPageview();
|
52
|
+
</script>
|
46
53
|
|
47
54
|
</body>
|
48
55
|
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classy-inheritance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Stone
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-30 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|