cache_column 0.1.2 → 0.1.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.
- data/Manifest +1 -1
- data/Rakefile +1 -1
- data/cache_column.gemspec +3 -3
- data/lib/cache_column.rb +32 -12
- metadata +5 -5
data/Manifest
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('cache_column', '0.1.
|
5
|
+
Echoe.new('cache_column', '0.1.3') do |p|
|
6
6
|
p.description = "Utilize the database to cache complex operations."
|
7
7
|
p.url = "http://github.com/arjes/Cache-Column"
|
8
8
|
p.author = "Brian Malinconico"
|
data/cache_column.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cache_column}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Brian Malinconico"]
|
9
|
-
s.date = %q{2010-08-
|
9
|
+
s.date = %q{2010-08-23}
|
10
10
|
s.description = %q{Utilize the database to cache complex operations.}
|
11
11
|
s.email = %q{arjesins@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/cache_column.rb", "lib/tasks/cache_column.rake"]
|
13
|
-
s.files = ["MIT-LICENSE", "
|
13
|
+
s.files = ["MIT-LICENSE", "README.rdoc", "Rakefile", "generators/cache_column/cache_column_generator.rb", "generators/cache_column/templates/cache_column_migration.rb.erb", "init.rb", "install.rb", "lib/cache_column.rb", "lib/tasks/cache_column.rake", "test/cache_column_test.rb", "test/test_helper.rb", "uninstall.rb", "Manifest", "cache_column.gemspec"]
|
14
14
|
s.homepage = %q{http://github.com/arjes/Cache-Column}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cache_column", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
data/lib/cache_column.rb
CHANGED
@@ -29,21 +29,33 @@ module CacheColumn
|
|
29
29
|
return if cached_columns.nil?
|
30
30
|
|
31
31
|
cached_columns.each do |key,params|
|
32
|
-
|
33
|
-
|
32
|
+
update_cache(key,params)
|
33
|
+
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
#self.cache_updated_at = Time.now if self.respond_to?(:cached_updated_at)
|
36
|
+
end
|
37
|
+
|
38
|
+
def update_cache(key, params=nil)
|
39
|
+
if params.nil?
|
40
|
+
cached_columns = self.class.instance_variable_get('@cached_columns')
|
41
|
+
params = cached_columns[key]
|
42
|
+
end
|
43
|
+
|
44
|
+
return if params.nil?
|
45
|
+
|
46
|
+
next if params[:update_validation].present? and self.respond_to?(params[:update_validation]) and self.send("#{params[:update_validation]}") == false
|
47
|
+
next if params[:on_save].blank?
|
42
48
|
|
43
|
-
|
49
|
+
if params[:on_save] == :blank
|
50
|
+
new_value = ""
|
51
|
+
set = true
|
52
|
+
elsif params[:on_save] == :recheck and params[:action].present? and self.respond_to?(params[:action].to_sym)
|
53
|
+
new_value = self.send(params[:action].to_sym)
|
54
|
+
set = true
|
44
55
|
end
|
45
56
|
|
46
|
-
#
|
57
|
+
self["#{key}_cache".to_sym] = new_value if set == true
|
58
|
+
|
47
59
|
end
|
48
60
|
|
49
61
|
|
@@ -62,7 +74,15 @@ module CacheColumn
|
|
62
74
|
cached_columns = self.class.instance_variable_get('@cached_columns')
|
63
75
|
|
64
76
|
if cached_columns.keys.include?(method) #then its a getter
|
65
|
-
|
77
|
+
cached_value = self["#{method}_cache".to_sym]
|
78
|
+
|
79
|
+
#If the cached_value is nil we should check to see if we can get a new value
|
80
|
+
if cached_value.nil?
|
81
|
+
update_cache(method)
|
82
|
+
cached_value = self["#{method}_cache".to_sym]
|
83
|
+
end
|
84
|
+
|
85
|
+
return cached_value
|
66
86
|
elsif method.to_s[-1,1] == '=' and cached_columns.keys.include?(method.to_s.chop.to_sym) and cached_columns[method.to_s.chop.to_sym][:action].blank? #then its a setter
|
67
87
|
return self["#{method.to_s.chop}_cache".to_sym] = arguments[0]
|
68
88
|
else
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_column
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Malinconico
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-23 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -31,7 +31,6 @@ extra_rdoc_files:
|
|
31
31
|
- lib/tasks/cache_column.rake
|
32
32
|
files:
|
33
33
|
- MIT-LICENSE
|
34
|
-
- Manifest
|
35
34
|
- README.rdoc
|
36
35
|
- Rakefile
|
37
36
|
- generators/cache_column/cache_column_generator.rb
|
@@ -43,6 +42,7 @@ files:
|
|
43
42
|
- test/cache_column_test.rb
|
44
43
|
- test/test_helper.rb
|
45
44
|
- uninstall.rb
|
45
|
+
- Manifest
|
46
46
|
- cache_column.gemspec
|
47
47
|
has_rdoc: true
|
48
48
|
homepage: http://github.com/arjes/Cache-Column
|