polymorphic_as_table 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,42 @@
1
+ = PolymorphicAsTable
2
+
3
+ I wrote this out of the need to deal with a legacy database that had the correct
4
+ schema for utlizing ActiveRecord[http://ar.rubyonrails.org/]'s polymorphic
5
+ associations, but required that the "type" columns contain the value of the
6
+ tablename they pointed to as opposed to the class name they resolved to.
7
+
8
+ There are probably bugs and cases where it will break that I haven't
9
+ found. _Please_ open bug reports to let me know about them, preferably with code
10
+ demonstrating the behaviour if possible, on the
11
+ bugtracker[https://github.com/jdodds/polymorphic_as_table/issues] on github.
12
+
13
+ In addition, I'm not exactly a Ruby or ActiveRecord guru. If I'm doing something
14
+ wrong, feel free to send a pull request. If you lend an explanation, I'll love
15
+ you forever.
16
+
17
+
18
+ = Usage
19
+
20
+ class MyPolymorphicModel < ActiveRecord::Base
21
+ is_polymorphic_as_table
22
+ belongs_to :entity, :polymorphic => true
23
+ end
24
+
25
+ class MyOtherModel < ActiveRecord::Base
26
+ has_polymorphic_as_table
27
+ has_many :my_polymorphic_models, :as => :entity
28
+ end
29
+
30
+
31
+ If you're testing with rspec-rails, you'll need to put the following at the top
32
+ of +config/environments/test.rb+ :
33
+
34
+ require 'active_record'
35
+ require 'active_record/associations'
36
+ require 'active_record/associations/through_association_scope'
37
+
38
+ This is due to ActiveRecord's use of autoload, and the way rspec-rails
39
+ initializes itself, I think. :/
40
+
41
+
42
+ Copyright (c) 2011 Jeremiah Dodds <jeremiah.dodds@gmail.com>, released under the MIT license
Binary file
@@ -12,14 +12,19 @@ PKG_FILES = Rake::FileList[
12
12
 
13
13
  Gem::Specification.new do |s|
14
14
  s.name = "polymorphic_as_table"
15
- s.version = "0.5.0"
15
+ s.version = "0.5.1"
16
16
  s.author = "Jeremiah Dodds"
17
17
  s.email = "jeremiah.dodds@gmail.com"
18
18
  s.homepage = "https://github.com/jdodds/polymorphic_as_table"
19
19
  s.platform = Gem::Platform::RUBY
20
20
  s.summary = "Allow for ActiveRecord polymorphic assocations that write their table name as their type"
21
+ s.description = <<-EOF
22
+ Monkey-patches ActiveRecord so that polymorphic associations have their type
23
+ column data written as their tablenames instead of their classnames. Intended
24
+ primarily for use in supporting legacy databases.
25
+ EOF
21
26
  s.files = PKG_FILES.to_a
22
27
  s.require_path = "lib"
23
28
  s.has_rdoc = false
24
- s.extra_rdoc_files = ["README"]
29
+ s.extra_rdoc_files = ["README.rdoc"]
25
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polymorphic_as_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,18 +11,26 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2011-08-26 00:00:00.000000000Z
13
13
  dependencies: []
14
- description:
14
+ description: ! 'Monkey-patches ActiveRecord so that polymorphic associations have
15
+ their type
16
+
17
+ column data written as their tablenames instead of their classnames. Intended
18
+
19
+ primarily for use in supporting legacy databases.
20
+
21
+ '
15
22
  email: jeremiah.dodds@gmail.com
16
23
  executables: []
17
24
  extensions: []
18
25
  extra_rdoc_files:
19
- - README
26
+ - README.rdoc
20
27
  files:
21
28
  - install.rb
22
29
  - uninstall.rb
30
+ - polymorphic_as_table-0.5.1.gem
23
31
  - polymorphic_as_table-0.5.0.gem
32
+ - README.rdoc
24
33
  - Rakefile
25
- - README
26
34
  - MIT-LICENSE
27
35
  - polymorphic_as_table.gemspec
28
36
  - lib/polymorphic_as_table.rb
data/README DELETED
@@ -1,13 +0,0 @@
1
- PolymorphicAsTable
2
- ==================
3
-
4
- Introduction goes here.
5
-
6
-
7
- Example
8
- =======
9
-
10
- Example goes here.
11
-
12
-
13
- Copyright (c) 2011 [name of plugin creator], released under the MIT license