build_associated 1.0.0 → 1.0.1

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.
@@ -1,3 +1,3 @@
1
1
  module BuildAssociated
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -9,7 +9,9 @@ module BuildAssociated
9
9
  remove_method association_name
10
10
 
11
11
  define_method association_name do
12
- self.send("_#{association_name}") || self.send("build_#{association_name}")
12
+ obj = self.send("_#{association_name}")
13
+ obj ||= self.send("build_#{association_name}") unless self.frozen? or self.readonly?
14
+ return obj
13
15
  end
14
16
  end
15
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build_associated
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &21016040 !ruby/object:Gem::Requirement
16
+ requirement: &18649340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21016040
24
+ version_requirements: *18649340
25
25
  description: Have ActiveRecord automagically build an association when accessed. Useful
26
26
  for belongs_to associations which should never be nil.
27
27
  email: