object_logging 0.2.0 → 0.2.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -39,6 +39,14 @@ module ObjectLogging
39
39
 
40
40
  module InstanceMethods
41
41
 
42
+ def object_logging
43
+ if instance_of?(Class)
44
+ self.metaclass.object_logging
45
+ else
46
+ self.class.object_logging
47
+ end
48
+ end
49
+
42
50
  def logger
43
51
  @logger ||= Logger.new(self)
44
52
  @logger.objectify(self)
@@ -30,7 +30,7 @@ module ObjectLogging
30
30
 
31
31
  def make_key(object, options)
32
32
  id = options[:id]
33
- if id.kind_of(Proc)
33
+ if id.kind_of?(Proc)
34
34
  key = id.call(object)
35
35
  else
36
36
  key = object.send(id)
@@ -38,7 +38,7 @@ module ObjectLogging
38
38
  private
39
39
 
40
40
  def instantiate_log(object)
41
- type, options = object.metaclass.object_logging
41
+ type, options = object.object_logging
42
42
  type = "base", options = {} if type.nil?
43
43
  class_name = type.to_s.split("_").collect{ |word| word.capitalize }.join
44
44
  klass = ObjectLogging::Log.const_get(class_name)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{object_logging}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christopher J. Bottaro"]
12
- s.date = %q{2010-05-11}
12
+ s.date = %q{2010-05-13}
13
13
  s.description = %q{It's a pain to trudge through large log files. Sometimes you just want to see log messages for one particular object.}
14
14
  s.email = %q{cjbottaro@alumni.cs.utexas.edu}
15
15
  s.extra_rdoc_files = [
@@ -49,9 +49,11 @@ class ObjectLoggingTest < Test::Unit::TestCase
49
49
  def test_inheritance
50
50
  p = Person.new
51
51
  s = Schmuck.new
52
- assert_equal p.class.object_logging, s.class.object_logging
53
- assert_not_equal p.class.object_logging.object_id, s.class.object_logging.object_id
54
- assert_equal([:rails_log, {}], s.class.object_logging)
52
+ assert_equal ObjectLogging::Log::RailsLog, p.logger.instance_variable_get("@log").class
53
+ assert_equal ObjectLogging::Log::RailsLog, s.logger.instance_variable_get("@log").class
54
+ assert_equal p.object_logging, s.object_logging
55
+ assert_not_equal p.object_logging.object_id, s.object_logging.object_id
56
+ assert_equal([:rails_log, {}], s.object_logging)
55
57
  end
56
58
 
57
59
  def test_static
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Christopher J. Bottaro
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-11 00:00:00 -05:00
17
+ date: 2010-05-13 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20