redcrumbs 0.3.8 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,13 +11,17 @@ module Redcrumbs
11
11
  end
12
12
 
13
13
  def full_subject
14
- self._subject ||= subject_type.classify.constantize.find(subject_id)
14
+ if self._subject.blank? || self._subject.new_record?
15
+ self._subject = subject_type.classify.constantize.find(subject_id)
16
+ else
17
+ self._subject
18
+ end
15
19
  end
16
20
 
17
21
  def subject_from_storage
18
- new_subject = subject_type.constantize.new(self.stored_subject)
19
- new_subject.id = self.stored_subject["id"] if self.stored_subject.has_key?("id")
20
- new_subject
22
+ self._subject ||= new_subject = subject_type.constantize.new(self.stored_subject.reject {|attribute| [:id].include?(attribute.to_sym)})
23
+ self._subject.id ||= self.stored_subject["id"] if self._subject.has_attribute?(:id) && self.stored_subject.has_key?("id")
24
+ self._subject
21
25
  end
22
26
 
23
27
  def creator
@@ -38,8 +42,13 @@ module Redcrumbs
38
42
  self._creator
39
43
  end
40
44
 
41
- def full_creator
42
- self._creator = creator_class.where(Redcrumbs.creator_primary_key => self.creator_id).first
45
+ # grabbing full creator/target should cache the result. Check to see is it a new_record (i.e. from storage) first
46
+ def full_creator
47
+ if self._creator.blank? || self._creator.new_record?
48
+ self._creator = creator_class.where(Redcrumbs.creator_primary_key => self.creator_id).first
49
+ else
50
+ self._creator
51
+ end
43
52
  end
44
53
 
45
54
  def target
@@ -61,7 +70,11 @@ module Redcrumbs
61
70
  end
62
71
 
63
72
  def full_target
64
- target_class.where(Redcrumbs.target_primary_key => self.target_id).first
73
+ if self._target.blank? || self._target.new_record?
74
+ self._target = target_class.where(Redcrumbs.target_primary_key => self.target_id).first
75
+ else
76
+ self._target
77
+ end
65
78
  end
66
79
  end
67
80
  end
@@ -1,3 +1,3 @@
1
1
  module Redcrumbs
2
- VERSION = "0.3.8"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcrumbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 +01:00
12
+ date: 2012-09-13 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: data_mapper
17
- requirement: &2152263540 !ruby/object:Gem::Requirement
17
+ requirement: &2151883460 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152263540
25
+ version_requirements: *2151883460
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: dm-redis-adapter
28
- requirement: &2152263040 !ruby/object:Gem::Requirement
28
+ requirement: &2151878000 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.6.2
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152263040
36
+ version_requirements: *2151878000
37
37
  description: Fast and unobtrusive activity tracking of ActiveRecord models using DataMapper
38
38
  and Redis
39
39
  email: