polymorphic_identity 0.0.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/MIT-LICENSE +20 -0
- data/README +70 -0
- data/Rakefile +80 -0
- data/init.rb +1 -0
- data/lib/polymorphic_identity.rb +57 -0
- data/test/app_root/app/models/article.rb +4 -0
- data/test/app_root/app/models/author.rb +4 -0
- data/test/app_root/app/models/comment.rb +6 -0
- data/test/app_root/app/models/page.rb +4 -0
- data/test/app_root/app/models/user.rb +4 -0
- data/test/app_root/config/boot.rb +13 -0
- data/test/app_root/config/database.yml +22 -0
- data/test/app_root/config/environment.rb +45 -0
- data/test/app_root/db/migrate/001_create_authors.rb +11 -0
- data/test/app_root/db/migrate/002_create_articles.rb +12 -0
- data/test/app_root/db/migrate/003_create_pages.rb +12 -0
- data/test/app_root/db/migrate/004_create_users.rb +11 -0
- data/test/app_root/db/migrate/005_create_comments.rb +14 -0
- data/test/app_root/test/fixtures/articles.yml +9 -0
- data/test/app_root/test/fixtures/authors.yml +7 -0
- data/test/app_root/test/fixtures/comments.yml +25 -0
- data/test/app_root/test/fixtures/pages.yml +9 -0
- data/test/app_root/test/fixtures/users.yml +7 -0
- data/test/test_helper.rb +31 -0
- data/test/unit/polymorphic_identity_test.rb +56 -0
- metadata +87 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2005-2006 Aaron Pfeifer & Neil Abraham
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
= polymorphic_identity
|
2
|
+
|
3
|
+
polymorphic_identity dynamically generates aliases for polymorphic associations
|
4
|
+
based on the class names of those associations.
|
5
|
+
|
6
|
+
== Resources
|
7
|
+
|
8
|
+
Wiki
|
9
|
+
|
10
|
+
* http://wiki.pluginaweek.org/Polymorphic_Identity
|
11
|
+
|
12
|
+
Announcement
|
13
|
+
|
14
|
+
* http://www.pluginaweek.org/2007/02/12/12-models-seek-damages-for-identity-theft
|
15
|
+
|
16
|
+
Source
|
17
|
+
|
18
|
+
* http://svn.pluginaweek.org/trunk/plugins/active_record/associations/polymorphic_identity
|
19
|
+
|
20
|
+
Development
|
21
|
+
|
22
|
+
* http://dev.pluginaweek.org/browser/trunk/plugins/active_record/associations/polymorphic_identity
|
23
|
+
|
24
|
+
== Description
|
25
|
+
|
26
|
+
Polymorphic associations are not very descriptive when it comes to easily
|
27
|
+
knowing the type of model your interacting with. For example, a typical
|
28
|
+
polymorphic assocation looks like the following:
|
29
|
+
|
30
|
+
class Tag < ActiveRecord::Base
|
31
|
+
belongs_to :taggable,
|
32
|
+
:polymorphic => true
|
33
|
+
end
|
34
|
+
|
35
|
+
When getting the taggable record, you would normally have to called
|
36
|
+
+tag.taggable+. However, if you know that the taggable record is just an
|
37
|
+
instance of the Article model, then it would feel more comfortable if you could
|
38
|
+
just called +tag.article+. polymoprhic_identity makes this possible by
|
39
|
+
dynamically checking the name of the polymorphic record's class and creating
|
40
|
+
methods that allow you to access the polymorphic association based on that
|
41
|
+
class name.
|
42
|
+
|
43
|
+
== Example
|
44
|
+
|
45
|
+
class Comment < ActiveRecord::Base
|
46
|
+
belongs_to :commentable,
|
47
|
+
:polymorphic => true
|
48
|
+
belongs_to :commenter,
|
49
|
+
:polymorphic => true
|
50
|
+
end
|
51
|
+
|
52
|
+
class Article < ActiveRecord::Base
|
53
|
+
has_many :comments, :as => :commentable
|
54
|
+
end
|
55
|
+
|
56
|
+
class User < ActiveRecord::Base
|
57
|
+
has_many :comments,
|
58
|
+
:as => :commenter
|
59
|
+
end
|
60
|
+
|
61
|
+
>> c = Comment.find(1)
|
62
|
+
=> #<Tag:0xb784d32c @attributes={"id"=>"1", "commentable_type"=>"Article", "commentable_id"=>"1", "commenter_type"=>"User", "commenter_id"=>"1"}>
|
63
|
+
>> c.commentable
|
64
|
+
=> #<Article:0xb779d5a8 @attributes={"id"=>"1"}>
|
65
|
+
>> c.article
|
66
|
+
=> #<Article:0xb779d5a8 @attributes={"id"=>"1"}>
|
67
|
+
>> c.commenter
|
68
|
+
=> #<User:0xb775d764 @attributes={"id"=>"1"}>
|
69
|
+
>> c.user
|
70
|
+
=> #<User:0xb775d764 @attributes={"id"=>"1"}>
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/contrib/sshpublisher'
|
5
|
+
|
6
|
+
PKG_NAME = 'polymorphic_identity'
|
7
|
+
PKG_VERSION = '0.0.1'
|
8
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
9
|
+
RUBY_FORGE_PROJECT = 'pluginaweek'
|
10
|
+
|
11
|
+
desc 'Default: run unit tests.'
|
12
|
+
task :default => :test
|
13
|
+
|
14
|
+
desc 'Test the polymorphic_identity plugin.'
|
15
|
+
Rake::TestTask.new(:test) do |t|
|
16
|
+
t.libs << 'lib'
|
17
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
18
|
+
t.verbose = true
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Generate documentation for the polymorphic_identity plugin.'
|
22
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
23
|
+
rdoc.rdoc_dir = 'rdoc'
|
24
|
+
rdoc.title = 'PolymorphicIdentity'
|
25
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
26
|
+
rdoc.rdoc_files.include('README')
|
27
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
28
|
+
end
|
29
|
+
|
30
|
+
spec = Gem::Specification.new do |s|
|
31
|
+
s.name = PKG_NAME
|
32
|
+
s.version = PKG_VERSION
|
33
|
+
s.platform = Gem::Platform::RUBY
|
34
|
+
s.summary = 'Dynamically generates aliases for polymorphic associations based on their class names'
|
35
|
+
|
36
|
+
s.files = FileList['{lib,tasks,test}/**/*'].to_a + %w(init.rb MIT-LICENSE Rakefile README)
|
37
|
+
s.require_path = 'lib'
|
38
|
+
s.autorequire = 'polymorphic_identity'
|
39
|
+
s.has_rdoc = true
|
40
|
+
s.test_files = Dir['test/unit/**/*_test.rb']
|
41
|
+
s.add_dependency 'activerecord', '>= 1.15.0'
|
42
|
+
|
43
|
+
s.author = 'Aaron Pfeifer and Neil Abraham'
|
44
|
+
s.email = 'info@pluginaweek.org'
|
45
|
+
s.homepage = 'http://www.pluginaweek.org'
|
46
|
+
end
|
47
|
+
|
48
|
+
Rake::GemPackageTask.new(spec) do |p|
|
49
|
+
p.gem_spec = spec
|
50
|
+
p.need_tar = true
|
51
|
+
p.need_zip = true
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Publish the beta gem'
|
55
|
+
task :pgem => [:package] do
|
56
|
+
Rake::SshFilePublisher.new('pluginaweek@pluginaweek.org', '/home/pluginaweek/gems.pluginaweek.org/gems', 'pkg', "#{PKG_FILE_NAME}.gem").upload
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'Publish the API documentation'
|
60
|
+
task :pdoc => [:rdoc] do
|
61
|
+
Rake::SshDirPublisher.new('pluginaweek@pluginaweek.org', "/home/pluginaweek/api.pluginaweek.org/#{PKG_NAME}", 'rdoc').upload
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'Publish the API docs and gem'
|
65
|
+
task :publish => [:pdoc, :release]
|
66
|
+
|
67
|
+
desc 'Publish the release files to RubyForge.'
|
68
|
+
task :release => [:gem, :package] do
|
69
|
+
require 'rubyforge'
|
70
|
+
|
71
|
+
ruby_forge = RubyForge.new
|
72
|
+
ruby_forge.login
|
73
|
+
|
74
|
+
%w( gem tgz zip ).each do |ext|
|
75
|
+
file = "pkg/#{PKG_FILE_NAME}.#{ext}"
|
76
|
+
puts "Releasing #{File.basename(file)}..."
|
77
|
+
|
78
|
+
ruby_forge.add_release(RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, file)
|
79
|
+
end
|
80
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'polymorphic_identity'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module PluginAWeek
|
2
|
+
# Adds dynamic attributes for polymorphic associations based on the name of
|
3
|
+
# the class for the polymorphic record. For example,
|
4
|
+
#
|
5
|
+
# class Tag < ActiveRecord::Base
|
6
|
+
# belongs_to :taggable, :polymorphic => true
|
7
|
+
# end
|
8
|
+
#
|
9
|
+
# class Article < ActiveRecord::Base
|
10
|
+
# has_many :tags, :as => :taggable
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# >> t = Tag.find(1)
|
14
|
+
# => #<Tag:0xb784d32c @attributes={"id"=>"1", "taggable_type"=>"Article", "taggable_id"=>"1"}>
|
15
|
+
# >> t.taggable
|
16
|
+
# => #<Article:0xb779d5a8 @attributes={"id"=>"1"}>
|
17
|
+
# >> t.article
|
18
|
+
# => #<Article:0xb779d5a8 @attributes={"id"=>"1"}>
|
19
|
+
module PolymorphicIdentity
|
20
|
+
def self.included(base) #:nodoc:
|
21
|
+
base.class_eval do
|
22
|
+
alias_method_chain :method_missing, :polymorphic_identity
|
23
|
+
alias_method_chain :respond_to?, :polymorphic_identity
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing_with_polymorphic_identity(method_id, *args, &block) #:nodoc:
|
28
|
+
if association_name = find_polymorphic_association_name(method_id)
|
29
|
+
send(association_name, *args, &block)
|
30
|
+
else
|
31
|
+
method_missing_without_polymorphic_identity(method_id, *args, &block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# True if a polymorphic association can be found whose foreign type is set
|
36
|
+
# to the name of the method
|
37
|
+
def respond_to_with_polymorphic_identity?(method, include_priv = false) #:nodoc:
|
38
|
+
respond_to_without_polymorphic_identity?(method, include_priv) || !find_polymorphic_association_name(method).nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
# Finds the name of the polymorphic association whose foreign type is set to
|
43
|
+
# the value specified.
|
44
|
+
def find_polymorphic_association_name(foreign_type_value)
|
45
|
+
foreign_type_value = foreign_type_value.to_s.camelize
|
46
|
+
reflection = self.class.reflections.values.find do |reflection|
|
47
|
+
reflection.options[:polymorphic] && read_attribute(reflection.options[:foreign_type]) == foreign_type_value
|
48
|
+
end
|
49
|
+
|
50
|
+
reflection ? reflection.name : nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
ActiveRecord::Base.class_eval do
|
56
|
+
include PluginAWeek::PolymorphicIdentity
|
57
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
unless defined?(APP_ROOT)
|
2
|
+
root_path = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
unless RUBY_PLATFORM =~ /mswin32/
|
5
|
+
require 'pathname'
|
6
|
+
root_path = Pathname.new(root_path).cleanpath(true).to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
APP_ROOT = root_path
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'active_record'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
in_memory:
|
2
|
+
adapter: sqlite3
|
3
|
+
database: ":memory:"
|
4
|
+
verbosity: quiet
|
5
|
+
sqlite:
|
6
|
+
adapter: sqlite
|
7
|
+
dbfile: polymorphic_identity_test.sqlite.db
|
8
|
+
sqlite3:
|
9
|
+
adapter: sqlite3
|
10
|
+
dbfile: polymorphic_identity_test.sqlite3.db
|
11
|
+
postgresql:
|
12
|
+
adapter: postgresql
|
13
|
+
username: postgres
|
14
|
+
password: postgres
|
15
|
+
database: polymorphic_identity_test
|
16
|
+
min_messages: ERROR
|
17
|
+
mysql:
|
18
|
+
adapter: mysql
|
19
|
+
host: localhost
|
20
|
+
username: root
|
21
|
+
password:
|
22
|
+
database: polymorphic_identity_test
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
2
|
+
|
3
|
+
# set_load_path
|
4
|
+
load_paths = %w(app app/models config vendor).collect {|dir| "#{APP_ROOT}/#{dir}"}
|
5
|
+
load_paths.reverse_each {|dir| $LOAD_PATH.unshift("#{APP_ROOT}/#{dir}") if File.directory?(dir)}
|
6
|
+
$LOAD_PATH.uniq!
|
7
|
+
|
8
|
+
# set_autoload_paths
|
9
|
+
Dependencies.load_paths = load_paths
|
10
|
+
|
11
|
+
# load_environment
|
12
|
+
APP_ENV = ENV['DB']
|
13
|
+
|
14
|
+
# initialize_database
|
15
|
+
ActiveRecord::Base.configurations = YAML::load(IO.read("#{APP_ROOT}/config/database.yml"))
|
16
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[APP_ENV])
|
17
|
+
|
18
|
+
# initializer_logger
|
19
|
+
log_path = "#{APP_ROOT}/log/#{APP_ENV}.log"
|
20
|
+
begin
|
21
|
+
logger = Logger.new(log_path)
|
22
|
+
logger.level = Logger::DEBUG
|
23
|
+
rescue StandardError
|
24
|
+
logger = Logger.new(STDERR)
|
25
|
+
logger.level = Logger::WARN
|
26
|
+
logger.warn(
|
27
|
+
"Logger Error: Unable to access log file. Please ensure that #{log_path} exists and is chmod 0666. " +
|
28
|
+
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
# initialize_framework_logging
|
33
|
+
ActiveRecord::Base.logger = logger
|
34
|
+
|
35
|
+
# initialize_dependency_mechanism
|
36
|
+
Dependencies.mechanism = :require
|
37
|
+
|
38
|
+
# initialize_breakpoints
|
39
|
+
require 'active_support/breakpoint'
|
40
|
+
|
41
|
+
# initialize_whiny_nils
|
42
|
+
# require('active_support/whiny_nil')
|
43
|
+
|
44
|
+
# load_observers
|
45
|
+
ActiveRecord::Base.instantiate_observers
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateComments < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :comments do |t|
|
4
|
+
t.column :commentable_id, :integer
|
5
|
+
t.column :commentable_type, :string
|
6
|
+
t.column :commenter_id, :string
|
7
|
+
t.column :commenter_type, :string
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :comments
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%
|
2
|
+
id = 0
|
3
|
+
[
|
4
|
+
[:article, :test, 1],
|
5
|
+
[:article, :welcome, 2],
|
6
|
+
[:page, :about, 1],
|
7
|
+
[:page, :projects, 2]
|
8
|
+
].each do |commentable_type, commentable_name, commentable_id|
|
9
|
+
[
|
10
|
+
[:author, :john_doe, 1],
|
11
|
+
[:author, :jane_doe, 2],
|
12
|
+
[:user, :anonymous, 1],
|
13
|
+
[:user, :registered, 2]
|
14
|
+
].each do |commenter_type, commenter_name, commenter_id|
|
15
|
+
%>
|
16
|
+
<%= commentable_type %>_<%= commentable_name %>_<%= commenter_type %>_<%= commenter_name %>:
|
17
|
+
id: <%= id += 1 %>
|
18
|
+
commentable_id: <%= commentable_id %>
|
19
|
+
commentable_type: <%= commentable_type.to_s.camelize %>
|
20
|
+
commenter_id: <%= commenter_id %>
|
21
|
+
commenter_type: <%= commenter_type.to_s.camelize %>
|
22
|
+
<%
|
23
|
+
end
|
24
|
+
end
|
25
|
+
%>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Load the environment
|
2
|
+
ENV['DB'] ||= 'in_memory'
|
3
|
+
require File.dirname(__FILE__) + '/app_root/config/environment.rb'
|
4
|
+
|
5
|
+
# Load the testing framework
|
6
|
+
require 'test/unit'
|
7
|
+
require 'active_record/fixtures'
|
8
|
+
|
9
|
+
# Load the plugin
|
10
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
11
|
+
require File.dirname(__FILE__) + '/../init'
|
12
|
+
|
13
|
+
# Run the migrations
|
14
|
+
ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate")
|
15
|
+
|
16
|
+
# Load fixtures
|
17
|
+
Test::Unit::TestCase.fixture_path = "#{APP_ROOT}/test/fixtures/"
|
18
|
+
$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
|
19
|
+
|
20
|
+
class Test::Unit::TestCase #:nodoc:
|
21
|
+
def create_fixtures(*table_names)
|
22
|
+
if block_given?
|
23
|
+
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
|
24
|
+
else
|
25
|
+
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
self.use_transactional_fixtures = true
|
30
|
+
self.use_instantiated_fixtures = false
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
Comment.class_eval do
|
4
|
+
public :find_polymorphic_association_name
|
5
|
+
end
|
6
|
+
|
7
|
+
class PolymorphicIdentityTest < Test::Unit::TestCase
|
8
|
+
fixtures :authors, :articles, :pages, :users, :comments
|
9
|
+
|
10
|
+
def test_find_polymorphic_association_name
|
11
|
+
c = Comment.new
|
12
|
+
c.commenter_type = 'Article'
|
13
|
+
assert_equal :commenter, c.find_polymorphic_association_name(:article)
|
14
|
+
assert_equal :commenter, c.find_polymorphic_association_name('article')
|
15
|
+
assert_equal nil, c.find_polymorphic_association_name('page')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_no_value
|
19
|
+
([Comment.new] + Comment.find(:all)).each do |c|
|
20
|
+
c.commentable = nil if c.commentable
|
21
|
+
c.commenter = nil if c.commenter
|
22
|
+
|
23
|
+
assert !c.respond_to?(:article)
|
24
|
+
assert !c.respond_to?(:page)
|
25
|
+
assert !c.respond_to?(:author)
|
26
|
+
assert !c.respond_to?(:user)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_existing_value
|
31
|
+
c = comments(:article_test_author_john_doe)
|
32
|
+
assert c.respond_to?(:article)
|
33
|
+
assert c.respond_to?(:author)
|
34
|
+
assert_equal articles(:test), c.article
|
35
|
+
assert_equal authors(:john_doe), c.author
|
36
|
+
|
37
|
+
c = comments(:page_about_user_anonymous)
|
38
|
+
assert c.respond_to?(:page)
|
39
|
+
assert c.respond_to?(:user)
|
40
|
+
assert_equal pages(:about), c.page
|
41
|
+
assert_equal users(:anonymous), c.user
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_change_value
|
45
|
+
c = comments(:article_test_author_john_doe)
|
46
|
+
c.commentable = pages(:about)
|
47
|
+
c.commenter = users(:anonymous)
|
48
|
+
|
49
|
+
assert !c.respond_to?(:article)
|
50
|
+
assert !c.respond_to?(:author)
|
51
|
+
assert c.respond_to?(:page)
|
52
|
+
assert c.respond_to?(:user)
|
53
|
+
assert_equal pages(:about), c.page
|
54
|
+
assert_equal users(:anonymous), c.user
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: polymorphic_identity
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-02-11 00:00:00 -05:00
|
8
|
+
summary: Dynamically generates aliases for polymorphic associations based on their class names
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: info@pluginaweek.org
|
12
|
+
homepage: http://www.pluginaweek.org
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: polymorphic_identity
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Aaron Pfeifer and Neil Abraham
|
31
|
+
files:
|
32
|
+
- lib/polymorphic_identity.rb
|
33
|
+
- test/unit
|
34
|
+
- test/test_helper.rb
|
35
|
+
- test/app_root
|
36
|
+
- test/unit/polymorphic_identity_test.rb
|
37
|
+
- test/app_root/app
|
38
|
+
- test/app_root/config
|
39
|
+
- test/app_root/db
|
40
|
+
- test/app_root/test
|
41
|
+
- test/app_root/app/models
|
42
|
+
- test/app_root/app/models/user.rb
|
43
|
+
- test/app_root/app/models/article.rb
|
44
|
+
- test/app_root/app/models/comment.rb
|
45
|
+
- test/app_root/app/models/author.rb
|
46
|
+
- test/app_root/app/models/page.rb
|
47
|
+
- test/app_root/config/boot.rb
|
48
|
+
- test/app_root/config/database.yml
|
49
|
+
- test/app_root/config/environment.rb
|
50
|
+
- test/app_root/db/migrate
|
51
|
+
- test/app_root/db/migrate/001_create_authors.rb
|
52
|
+
- test/app_root/db/migrate/002_create_articles.rb
|
53
|
+
- test/app_root/db/migrate/003_create_pages.rb
|
54
|
+
- test/app_root/db/migrate/004_create_users.rb
|
55
|
+
- test/app_root/db/migrate/005_create_comments.rb
|
56
|
+
- test/app_root/test/fixtures
|
57
|
+
- test/app_root/test/fixtures/articles.yml
|
58
|
+
- test/app_root/test/fixtures/authors.yml
|
59
|
+
- test/app_root/test/fixtures/comments.yml
|
60
|
+
- test/app_root/test/fixtures/pages.yml
|
61
|
+
- test/app_root/test/fixtures/users.yml
|
62
|
+
- init.rb
|
63
|
+
- MIT-LICENSE
|
64
|
+
- Rakefile
|
65
|
+
- README
|
66
|
+
test_files:
|
67
|
+
- test/unit/polymorphic_identity_test.rb
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
72
|
+
executables: []
|
73
|
+
|
74
|
+
extensions: []
|
75
|
+
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
dependencies:
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: activerecord
|
81
|
+
version_requirement:
|
82
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.15.0
|
87
|
+
version:
|