public
Description: Allows the caching of lookup data in your Rails models
Clone URL: git://github.com/vigetlabs/constant_cache.git
Renamed files
Use different approach to extending AR::Base
Old to_const method moved to String#constant_name

git-svn-id: 
http://svn.extendviget.com/lab/trunk/plugins/caches_constants@135 
e959a6d6-1924-0410-92b3-a6fa492f4c66
reagent (author)
Tue Jul 03 14:14:28 -0700 2007
commit  97a5aa7b0189ed84282aba95d51e3051059ca3d1
tree    b78754271312cb917757fa0581a94ffab066e563
parent  59f81978ebd922d3ad3870f5102f591cf5880e04
...
1
2
 
 
 
 
...
 
 
1
2
3
4
0
@@ -1,2 +1,4 @@
0
-require 'viget/format'
0
-require 'caches_constants'
0
+require 'format'
0
+require 'constant_cache'
0
+
0
+ActiveRecord::Base.send(:extend, Viget::ConstantCache::ClassMethods)
...
2
3
4
5
6
 
 
7
8
9
10
 
 
11
12
13
14
 
 
15
16
17
18
 
 
19
20
21
22
 
 
23
24
25
26
...
2
3
4
 
 
5
6
7
8
 
 
9
10
11
12
 
 
13
14
15
16
 
 
17
18
19
20
 
 
21
22
23
24
25
26
0
@@ -2,24 +2,24 @@ require File.dirname(__FILE__) + '/../test_helper'
0
 
0
 class FormatTest < Test::Unit::TestCase
0
   
0
- def test_to_const_should_uppercase_characters
0
- assert_equal 'Test', Viget::Format.to_const('test')
0
+ def test_constant_name_should_uppercase_characters
0
+ assert_equal 'Test', 'test'.constant_name
0
   end
0
   
0
- def test_to_const_should_replace_whitespace_with_single_underscore
0
- assert_equal 'TestThisFormatPlease', Viget::Format.to_const("test this format\tplease")
0
+ def test_constant_name_should_replace_whitespace_with_single_underscore
0
+ assert_equal 'TestThisFormatPlease', "test this format\tplease".constant_name
0
   end
0
   
0
- def test_to_const_should_remove_leading_and_trailing_whitespace
0
- assert_equal 'Test', Viget::Format.to_const(' test ')
0
+ def test_constant_name_should_remove_leading_and_trailing_whitespace
0
+ assert_equal 'Test', ' test '.constant_name
0
   end
0
   
0
- def test_to_const_should_remove_non_word_characters
0
- assert_equal 'Test', Viget::Format.to_const('!test.?')
0
+ def test_constant_name_should_remove_non_word_characters
0
+ assert_equal 'Test', '!test.?'.constant_name
0
   end
0
   
0
- def test_to_const_should_return_nil_if_all_chars_removed
0
- assert_nil Viget::Format.to_const('?')
0
+ def test_constant_name_should_return_nil_if_all_chars_removed
0
+ assert_nil '?'.constant_name
0
   end
0
   
0
 end
0
\ No newline at end of file
...
4
5
6
7
8
9
 
 
 
 
10
...
4
5
6
 
 
7
8
9
10
11
12
0
@@ -4,5 +4,7 @@ require 'rubygems'
0
 require 'test/unit'
0
 require 'mocha'
0
 require 'active_record'
0
-require "#{lib_dir}/viget/format"
0
-require "#{lib_dir}/caches_constants"
0
\ No newline at end of file
0
+require "#{lib_dir}/format"
0
+require "#{lib_dir}/constant_cache"
0
+
0
+ActiveRecord::Base.send(:extend, Viget::ConstantCache::ClassMethods)
0
\ No newline at end of file

Comments

    No one has commented yet.