peek-active_record 0.2.0 → 0.3.0
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/README.md +4 -0
- data/lib/peek/active_record/object_stats.rb +13 -0
- data/lib/peek/extensions/active_record.rb +2 -22
- data/peek-active_record.gemspec +1 -1
- metadata +2 -1
data/README.md
CHANGED
@@ -28,6 +28,10 @@ Peek.into Peek::Views::ActiveRecord
|
|
28
28
|
#= require 'peek/views/active_record'
|
29
29
|
```
|
30
30
|
|
31
|
+
Then, in any ActiveRecord model you wish to watch allocations of
|
32
|
+
(please note that after_initialize does impair performance of your app slightly)
|
33
|
+
simply include the `Peek::ActiveRecord::ObjectStats` module.
|
34
|
+
|
31
35
|
## Contributing
|
32
36
|
|
33
37
|
1. Fork it
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "active_record"
|
2
2
|
require "atomic"
|
3
3
|
|
4
|
+
require "peek/active_record/object_stats"
|
5
|
+
|
4
6
|
class ActiveRecord::Base
|
5
7
|
class << self
|
6
8
|
attr_accessor :obj_count, :obj_types, :obj_types_enabled
|
@@ -10,28 +12,6 @@ class ActiveRecord::Base
|
|
10
12
|
self.obj_types = Hash.new(0)
|
11
13
|
self.obj_types_enabled = false
|
12
14
|
|
13
|
-
def initialize_with_stats *attributes
|
14
|
-
initialize_without_stats *attributes
|
15
|
-
ensure
|
16
|
-
_update_object_stats
|
17
|
-
end
|
18
|
-
|
19
|
-
def init_with_with_stats coder
|
20
|
-
init_with_without_stats coder
|
21
|
-
ensure
|
22
|
-
_update_object_stats
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize_dup_with_stats other
|
26
|
-
intialize_dup_without_stats other
|
27
|
-
ensure
|
28
|
-
_update_object_stats
|
29
|
-
end
|
30
|
-
|
31
|
-
alias_method_chain :initialize, :stats
|
32
|
-
alias_method_chain :init_with, :stats
|
33
|
-
alias_method_chain :initialize_dup, :stats
|
34
|
-
|
35
15
|
protected
|
36
16
|
def _update_object_stats
|
37
17
|
ActiveRecord::Base.obj_count.update { |val| val + 1 }
|
data/peek-active_record.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peek-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- app/views/peek/views/_active_record.html.erb
|
108
108
|
- lib/peek-active_record.rb
|
109
109
|
- lib/peek-active_record/railtie.rb
|
110
|
+
- lib/peek/active_record/object_stats.rb
|
110
111
|
- lib/peek/extensions/active_record.rb
|
111
112
|
- lib/peek/views/active_record.rb
|
112
113
|
- peek-active_record.gemspec
|