property_sets 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.5.0
@@ -14,7 +14,7 @@ module PropertySets
14
14
  property_class = PropertySets.ensure_property_set_class(association, self)
15
15
  property_class.instance_eval(&block)
16
16
 
17
- has_many association, :class_name => property_class.name, :dependent => :destroy do
17
+ has_many association, :class_name => property_class.name, :autosave => true, :dependent => :destroy do
18
18
 
19
19
  # Accepts a name value pair hash { :name => 'value', :pairs => true } and builds a property for each key
20
20
  def set(property_pairs, with_protection = false)
@@ -61,7 +61,6 @@ module PropertySets
61
61
  define_method "#{key}=" do |value|
62
62
  instance = lookup(key)
63
63
  instance.value = value
64
- @owner.send(association) << instance
65
64
  value
66
65
  end
67
66
 
@@ -45,12 +45,6 @@ module PropertySets
45
45
  def owner_class_instance
46
46
  send(self.class.owner_class_sym)
47
47
  end
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
48
  end
55
49
 
56
50
  module ClassMethods
@@ -81,11 +75,6 @@ module PropertySets
81
75
  belongs_to owner_class_sym
82
76
  validates_presence_of owner_class_sym
83
77
  validates_uniqueness_of :name, :scope => owner_class_key_sym
84
-
85
- if owner_class.table_exists? && owner_class.column_names.include?("updated_at")
86
- before_create :update_owner_timestamp
87
- before_destroy :update_owner_timestamp
88
- end
89
78
  end
90
79
 
91
80
  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.4.4"
8
+ s.version = "0.5.0"
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-29}
12
+ s.date = %q{2011-04-15}
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 = [
@@ -102,8 +102,11 @@ class TestPropertySets < ActiveSupport::TestCase
102
102
 
103
103
  should "coerce everything but nil to string" do
104
104
  @account.settings.foo = 3
105
+ assert @account.settings.foo == 3
106
+ @account.save
105
107
  assert @account.settings.foo == "3"
106
108
  @account.settings.foo = nil
109
+ @account.save
107
110
  assert @account.settings.foo.nil?
108
111
  end
109
112
 
@@ -124,10 +127,8 @@ class TestPropertySets < ActiveSupport::TestCase
124
127
  context "validations" do
125
128
  should "add an error when violated" do
126
129
  @account.validations.validated = "hello"
127
- assert_equal "Value BEEP", @account.validations.first.errors.full_messages.first
128
- assert_equal "Value BEEP", @account.validations.validated_record.errors.full_messages.first
129
- assert_equal false, @account.save
130
- assert_equal "Validations is invalid", @account.errors.full_messages.first
130
+ assert !@account.valid?
131
+ assert_equal "Value BEEP", @account.errors.full_messages.first
131
132
  end
132
133
  end
133
134
 
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: 7
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 4
10
- version: 0.4.4
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
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-29 00:00:00 -07:00
18
+ date: 2011-04-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency