property_sets 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/property_sets/active_record_extension.rb +5 -1
- data/property_sets.gemspec +2 -2
- data/test/test_property_sets.rb +8 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
@@ -68,7 +68,11 @@ module PropertySets
|
|
68
68
|
# The finder method which returns the property if present, otherwise a new instance with defaults
|
69
69
|
define_method "lookup" do |arg|
|
70
70
|
instance = detect { |property| property.name.to_sym == arg.to_sym }
|
71
|
-
instance ||=
|
71
|
+
instance ||= build(:name => arg.to_s, :value => property_class.default(arg))
|
72
|
+
|
73
|
+
instance.send("#{owner_class_sym}=", @owner) if @owner.new_record?
|
74
|
+
|
75
|
+
instance
|
72
76
|
end
|
73
77
|
|
74
78
|
# This finder method returns the property if present,
|
data/property_sets.gemspec
CHANGED
@@ -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.
|
8
|
+
s.version = "0.4.3"
|
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-
|
12
|
+
s.date = %q{2011-03-29}
|
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 = [
|
data/test/test_property_sets.rb
CHANGED
@@ -113,6 +113,14 @@ class TestPropertySets < ActiveSupport::TestCase
|
|
113
113
|
assert record.account.id == @account.id
|
114
114
|
end
|
115
115
|
|
116
|
+
should "reference the owner instance when constructing a new record ...on a new record" do
|
117
|
+
account = Account.new(:name => "New")
|
118
|
+
record = account.settings.lookup(:baz)
|
119
|
+
|
120
|
+
assert record.new_record?
|
121
|
+
assert record.account == account
|
122
|
+
end
|
123
|
+
|
116
124
|
context "validations" do
|
117
125
|
should "add an error when violated" do
|
118
126
|
@account.validations.validated = "hello"
|
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:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
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-
|
18
|
+
date: 2011-03-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|