property_sets 0.3.6 → 0.4.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.3.6
1
+ 0.4.0
@@ -63,8 +63,8 @@ module PropertySets
63
63
 
64
64
  # The finder method which returns the property if present, otherwise a new instance with defaults
65
65
  define_method "lookup" do |arg|
66
- instance = detect { |property| property.name.to_sym == arg }
67
- instance ||= property_class.new(@owner.class.name.underscore.to_sym => @owner, :name => arg.to_s, :value => property_class.default(arg))
66
+ instance = detect { |property| property.name.to_sym == arg.to_sym }
67
+ instance ||= @owner.send(association).build(:name => arg.to_s, :value => property_class.default(arg))
68
68
  end
69
69
  end
70
70
  end
@@ -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.6"
8
+ s.version = "0.4.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-04}
12
+ s.date = %q{2011-03-07}
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 = [
@@ -29,6 +29,11 @@ class TestPropertySets < ActiveSupport::TestCase
29
29
  assert !@account.settings.hep?
30
30
  @account.settings.enable(:hep)
31
31
  assert @account.settings.hep?
32
+
33
+ account = Account.new
34
+ assert !account.settings.foo?
35
+ account.settings.enable(:foo)
36
+ assert account.settings.foo?
32
37
  end
33
38
 
34
39
  should "be empty on a new account" do
@@ -104,6 +109,12 @@ class TestPropertySets < ActiveSupport::TestCase
104
109
  assert @account.settings.bar?
105
110
  end
106
111
 
112
+ should "convert string keys to symbols to ensure consistent lookup" do
113
+ @account.settings.set(:foo => "123")
114
+ @account.settings.set("foo" => "456")
115
+ assert @account.save!
116
+ end
117
+
107
118
  should "work identically for new and existing owner objects" do
108
119
  [ @account, Account.new(:name => "Mibble") ].each do |account|
109
120
  account.settings.set(:foo => "123", :bar => "456")
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: 31
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 6
10
- version: 0.3.6
8
+ - 4
9
+ - 0
10
+ version: 0.4.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-04 00:00:00 -08:00
18
+ date: 2011-03-07 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency