property_sets 0.3.5 → 0.3.6

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.3.5
1
+ 0.3.6
@@ -46,6 +46,12 @@ module PropertySets
46
46
  send(self.class.owner_class_sym)
47
47
  end
48
48
 
49
+ def update_owner_timestamp
50
+ if owner_class_instance && !owner_class_instance.new_record? && owner_class_instance.updated_at < 1.second.ago
51
+ owner_class_instance.update_attribute(:updated_at, Time.now)
52
+ end
53
+ end
54
+
49
55
  def reset_owner_association
50
56
  owner_class_instance.send(self.class.owner_assoc).reload
51
57
  end
@@ -78,9 +84,14 @@ module PropertySets
78
84
 
79
85
  def owner_class=(owner_class)
80
86
  @owner_class_sym = owner_class.name.underscore.to_sym
81
- belongs_to owner_class_sym, :touch => true
87
+ belongs_to owner_class_sym
82
88
  validates_presence_of owner_class_sym
83
89
  validates_uniqueness_of :name, :scope => owner_class_key_sym
90
+
91
+ if owner_class.table_exists? && owner_class.column_names.include?("updated_at")
92
+ before_create :update_owner_timestamp
93
+ before_destroy :update_owner_timestamp
94
+ end
84
95
  end
85
96
 
86
97
  def owner_assoc=(association)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{property_sets}
8
- s.version = "0.3.5"
8
+ s.version = "0.3.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Morten Primdahl"]
12
- s.date = %q{2011-03-03}
12
+ s.date = %q{2011-03-04}
13
13
  s.description = %q{This gem is an ActiveRecord extension which provides a convenient interface for managing per row properties}
14
14
  s.email = %q{morten@zendesk.com}
15
15
  s.extra_rdoc_files = [
@@ -93,7 +93,6 @@ class TestPropertySets < ActiveSupport::TestCase
93
93
  assert record.account.id == @account.id
94
94
  end
95
95
 
96
-
97
96
  context "#set" do
98
97
  should "support writing multiple values to the association" do
99
98
  assert !@account.settings.foo?
@@ -122,12 +121,6 @@ class TestPropertySets < ActiveSupport::TestCase
122
121
  end
123
122
  end
124
123
 
125
- should "touch the owner instance" do #Ding!
126
- @account.expects(:touch)
127
- record = @account.settings.lookup(:baz)
128
- record.update_attributes!(:value => "foo")
129
- end
130
-
131
124
  should "be updateable as AR nested attributes" do
132
125
  assert @account.texts_attributes = [{ :name => "foo", :value => "1" }, { :name => "bar", :value => "0" }]
133
126
  @account.save!
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: property_sets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-03 00:00:00 -08:00
18
+ date: 2011-03-04 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency