slim_scrooge 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -113,3 +113,4 @@ h2. References
113
113
  h2. Authors
114
114
  * Stephen Sykes (sdsykes)
115
115
  * Special thanks to Lourens Naudé (methodmissing) for the original idea, and the C implementation of callsite_hash as well as some other bits of code that I borrowed from the original project.
116
+ * Thanks to Steve Purcell for fixes and help
data/Rakefile CHANGED
@@ -9,21 +9,3 @@ Rake::TestTask.new(:test_with_active_record) do |t|
9
9
  t.ruby_opts = ["-r #{File.join(File.dirname(__FILE__), 'test', 'active_record_setup')}"]
10
10
  t.verbose = true
11
11
  end
12
-
13
- begin
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |s|
16
- s.name = "slim_scrooge"
17
- s.summary = "Slim_scrooge - serious optimisation for ActiveRecord"
18
- s.email = "sdsykes@gmail.com"
19
- s.homepage = "http://github.com/sdsykes/slim_scrooge"
20
- s.description = "Slim scrooge boosts speed in Rails ActiveRecord Models by only querying the database for what is needed."
21
- s.authors = ["Stephen Sykes"]
22
- s.files = FileList["[A-Z]*", "{ext,lib,test}/**/*"]
23
- s.extensions = "ext/Rakefile"
24
- end
25
- Jeweler::GemcutterTasks.new
26
- rescue LoadError
27
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://
28
- gems.github.com"
29
- end
data/VERSION.yml CHANGED
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :build:
4
4
  :minor: 0
5
- :patch: 10
5
+ :patch: 11
@@ -29,7 +29,7 @@ module SlimScrooge
29
29
  #
30
30
  def new_column_access(name)
31
31
  if @callsite.columns_hash.has_key?(name)
32
- @result_set.reload! if @result_set && name != @callsite.primary_key
32
+ @result_set.reload! if !@result_set.nil? && name != @callsite.primary_key
33
33
  Callsites.add_seen_column(@callsite, name)
34
34
  end
35
35
  @monitored_columns[name]
@@ -40,7 +40,7 @@ module SlimScrooge
40
40
  def []=(name, value)
41
41
  if has_key?(name)
42
42
  return super
43
- elsif @result_set && @callsite.columns_hash.has_key?(name)
43
+ elsif !@result_set.nil? && @callsite.columns_hash.has_key?(name)
44
44
  @result_set.reload!
45
45
  Callsites.add_seen_column(@callsite, name)
46
46
  end
@@ -50,13 +50,13 @@ module SlimScrooge
50
50
  # Returns the column names
51
51
  #
52
52
  def keys
53
- @result_set ? @callsite.columns_hash.keys : super | @monitored_columns.keys
53
+ !@result_set.nil? ? @callsite.columns_hash.keys : super | @monitored_columns.keys
54
54
  end
55
55
 
56
56
  # Check for a column name
57
57
  #
58
58
  def has_key?(name)
59
- @result_set ? @callsite.columns_hash.has_key?(name) : super || @monitored_columns.has_key?(name)
59
+ !@result_set.nil? ? @callsite.columns_hash.has_key?(name) : super || @monitored_columns.has_key?(name)
60
60
  end
61
61
 
62
62
  alias_method :include?, :has_key?
@@ -64,12 +64,12 @@ module SlimScrooge
64
64
  # Called by Hash#update when reload is called on an ActiveRecord object
65
65
  #
66
66
  def to_hash
67
- @result_set.reload! if @result_set
67
+ @result_set.reload! unless @result_set.nil?
68
68
  @monitored_columns.merge(self)
69
69
  end
70
70
 
71
71
  def freeze
72
- @result_set.reload! if @result_set
72
+ @result_set.reload! unless @result_set.nil?
73
73
  @monitored_columns.freeze
74
74
  super
75
75
  end
@@ -87,17 +87,19 @@ module SlimScrooge
87
87
  end
88
88
  end
89
89
 
90
- # We need to change the update method of Hash so that it *always* calls
91
- # to_hash. This is because it normally checks if other_hash is a kind of
92
- # Hash, and doesn't bother calling to_hash if so. But we need it to call
93
- # to_hash, because otherwise update will not get the complete columns
94
- # from a MonitoredHash
90
+ # We need to change the update method of Hash so that it *always*
91
+ # calls to_hash on MonitoredHash instances. This is because it
92
+ # normally checks if other_hash is a kind of Hash, and doesn't bother
93
+ # calling to_hash if so. But we need it to call to_hash, because
94
+ # otherwise update will not get the complete columns from a
95
+ # MonitoredHash
95
96
  #
96
97
  # This is not harmful - to_hash in a regular Hash just returns self.
97
98
  #
98
99
  class Hash
99
100
  alias_method :c_update, :update
100
101
  def update(other_hash, &block)
101
- c_update(other_hash.to_hash, &block)
102
+ c_update(other_hash.is_a?(::SlimScrooge::MonitoredHash) ? other_hash.to_hash : other_hash,
103
+ &block)
102
104
  end
103
105
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_scrooge
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 1
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 10
9
- version: 1.0.10
9
+ - 11
10
+ version: 1.0.11
10
11
  platform: ruby
11
12
  authors:
12
13
  - Stephen Sykes
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-02 00:00:00 +03:00
18
+ date: 2010-12-20 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -55,23 +56,27 @@ rdoc_options:
55
56
  require_paths:
56
57
  - lib
57
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
58
60
  requirements:
59
61
  - - ">="
60
62
  - !ruby/object:Gem::Version
63
+ hash: 3
61
64
  segments:
62
65
  - 0
63
66
  version: "0"
64
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
65
69
  requirements:
66
70
  - - ">="
67
71
  - !ruby/object:Gem::Version
72
+ hash: 3
68
73
  segments:
69
74
  - 0
70
75
  version: "0"
71
76
  requirements: []
72
77
 
73
78
  rubyforge_project:
74
- rubygems_version: 1.3.6
79
+ rubygems_version: 1.3.7
75
80
  signing_key:
76
81
  specification_version: 3
77
82
  summary: Slim_scrooge - serious optimisation for ActiveRecord