acts_as_singleton 0.0.2 → 0.0.3

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.
@@ -1,3 +1,10 @@
1
+ === 0.0.3 / 2009-11-29
2
+
3
+ * 1 bugfix
4
+
5
+ * Don't make ActiveRecord::Base.allocate private.
6
+
7
+
1
8
  === 0.0.2 / 2009-04-13
2
9
 
3
10
  * 1 minor enhancement
@@ -53,21 +53,15 @@ Don't even try to access it otherwise. It won't work!
53
53
 
54
54
  === As a gem
55
55
 
56
- From RubyForge:
56
+ Configure:
57
57
 
58
- % gem install acts_as_singleton
58
+ # config/environment.rb
59
+ config.gem "acts_as_singleton"
59
60
 
60
61
 
61
- Or GitHub:
62
+ And install:
62
63
 
63
- % gem install stephencelis-acts_as_singleton --source=http://gems.github.com
64
-
65
-
66
- And configure:
67
-
68
- config.gem "stephencelis-acts_as_singleton",
69
- :lib => "acts_as_singleton",
70
- :source => "http://gems.github.com"
64
+ % rake gems:install
71
65
 
72
66
 
73
67
  === As a plugin
@@ -89,11 +83,11 @@ Or, as a submodule:
89
83
 
90
84
  (c) 2009-* Stephen Celis, stephen@stephencelis.com.
91
85
 
92
- Permission is hereby granted, free of charge, to any person obtaining a copy
93
- of this software and associated documentation files (the "Software"), to deal
94
- in the Software without restriction, including without limitation the rights
95
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
96
- copies of the Software, and to permit persons to whom the Software is
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to deal
88
+ in the Software without restriction, including without limitation the rights
89
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
90
+ copies of the Software, and to permit persons to whom the Software is
97
91
  furnished to do so, subject to the following conditions:
98
92
 
99
93
  The above copyright notice and this permission notice shall be included in all
data/Rakefile CHANGED
@@ -1,15 +1,8 @@
1
1
  $: << File.dirname(__FILE__) + "/lib"
2
2
  require "rubygems"
3
- require "hoe"
4
3
  require "active_record"
5
4
  require "acts_as_singleton"
6
5
 
7
- Hoe.new("acts_as_singleton", ActiveRecord::Singleton::VERSION) do |p|
8
- p.developer("Stephen Celis", "stephen@stephencelis.com")
9
- p.remote_rdoc_dir = ''
10
- p.rubyforge_name = %q{actsassingleton}
11
- end
12
-
13
6
  require 'rake'
14
7
  require 'rake/testtask'
15
8
  require 'rake/rdoctask'
@@ -21,7 +21,8 @@ module ActiveRecord
21
21
 
22
22
  # This pattern matches methods that should be made private because they
23
23
  # should not be used in singleton classes.
24
- PRIVATE = /^all(?:oc.*)?$|alloc|create|find|firs|mini|max|new|d_sco|^upd/
24
+ # PRIVATE = /^all(?:oc.*)?$|alloc|create|find|firs|mini|max|new|d_sco|^upd/
25
+ PRIVATE = /^all$|create|find|firs|mini|max|new|d_sco|^upd/
25
26
 
26
27
  def self.included(model)
27
28
  model.class_eval do
@@ -4,11 +4,13 @@ require 'active_record'
4
4
  require "#{File.dirname(__FILE__)}/../init"
5
5
  require 'active_support'
6
6
  require 'active_support/test_case'
7
+ ActiveRecord::Migration.verbose = false
7
8
 
8
9
  def setup_db
9
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
10
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
10
11
  ActiveRecord::Schema.define(:version => 1) do
11
12
  create_table :homepage_settings do |t|
13
+ t.string :type
12
14
  t.text :welcome_message
13
15
  t.timestamp :published_at, :expired_at
14
16
  end
@@ -26,6 +28,9 @@ class HomepageSettings < ActiveRecord::Base
26
28
  acts_as_singleton
27
29
  end
28
30
 
31
+ class LoggedInSettings < HomepageSettings
32
+ end
33
+
29
34
  class ActsAsSingletonTest < ActiveSupport::TestCase
30
35
  setup do
31
36
  setup_db
@@ -71,4 +76,14 @@ class ActsAsSingletonTest < ActiveSupport::TestCase
71
76
  HomepageSettings.instance.update_attributes! :welcome_message => "OH HAI"
72
77
  end
73
78
  end
79
+
80
+ test "should honor STI" do
81
+ ActiveRecord::Base.logger = STDOUT
82
+ ActiveRecord::Base.clear_active_connections!
83
+ HomepageSettings.instance # Fetch parent.
84
+ LoggedInSettings.instance # Fetch child.
85
+ assert_nothing_raised ActiveRecord::SubclassNotFound do
86
+ LoggedInSettings.instance # Fetch again.
87
+ end
88
+ end
74
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_singleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Celis
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-13 00:00:00 -05:00
12
+ date: 2009-11-29 00:00:00 -05:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.12.1
24
- version:
14
+ dependencies: []
15
+
25
16
  description: "A lightweight singleton library for your Active Record models. It just makes sense to store mutable, site-wide, admin-level settings in the database. Right? A key-value table may be more flexible, but maybe we don't want to be flexible! If you truly want that flexibility: http://github.com/stephencelis/kvc"
26
17
  email:
27
18
  - stephen@stephencelis.com
@@ -30,13 +21,13 @@ executables: []
30
21
  extensions: []
31
22
 
32
23
  extra_rdoc_files:
33
- - History.txt
24
+ - History.rdoc
34
25
  - Manifest.txt
35
- - README.txt
26
+ - README.rdoc
36
27
  files:
37
- - History.txt
28
+ - History.rdoc
38
29
  - Manifest.txt
39
- - README.txt
30
+ - README.rdoc
40
31
  - Rakefile
41
32
  - init.rb
42
33
  - lib/acts_as_singleton.rb
@@ -48,7 +39,7 @@ licenses: []
48
39
  post_install_message:
49
40
  rdoc_options:
50
41
  - --main
51
- - README.txt
42
+ - README.rdoc
52
43
  require_paths:
53
44
  - lib
54
45
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -68,7 +59,7 @@ requirements: []
68
59
  rubyforge_project: actsassingleton
69
60
  rubygems_version: 1.3.5
70
61
  signing_key:
71
- specification_version: 2
62
+ specification_version: 3
72
63
  summary: A lightweight singleton library for your Active Record models
73
64
  test_files: []
74
65