modelfactory 0.8.0 → 0.8.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.
- data/History.txt +4 -0
- data/lib/model_factory.rb +6 -6
- data/lib/model_factory/version.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/lib/model_factory.rb
CHANGED
@@ -13,9 +13,9 @@ module ModelFactory
|
|
13
13
|
# object as a dependency use the special method default_* instead of
|
14
14
|
# create_* or new_*.
|
15
15
|
#
|
16
|
-
def default(class_type, *
|
17
|
-
defaults =
|
18
|
-
prefix =
|
16
|
+
def default(class_type, *default_args)
|
17
|
+
defaults = default_args.pop || {}
|
18
|
+
prefix = default_args.first
|
19
19
|
class_name = class_type.name.demodulize.underscore
|
20
20
|
class_name = "#{prefix}_#{class_name}" if prefix
|
21
21
|
|
@@ -57,8 +57,8 @@ module ModelFactory
|
|
57
57
|
def default_closure(class_type, attributes, defaults = {}) # :nodoc:
|
58
58
|
lambda do |create_or_new|
|
59
59
|
case create_or_new
|
60
|
-
when :new
|
61
|
-
when :create
|
60
|
+
when :new ; new_instance(class_type, attributes, defaults)
|
61
|
+
when :create ; create_instance(class_type, attributes, defaults)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -82,7 +82,7 @@ module ModelFactory
|
|
82
82
|
if protected_attrs or accessible_attrs
|
83
83
|
attributes.each do |key, value|
|
84
84
|
# Support symbols and strings.
|
85
|
-
next if protected_attrs and not
|
85
|
+
next if protected_attrs and (not protected_attrs.include?(key) or protected_attrs.include?(key.to_s))
|
86
86
|
next if accessible_attrs and (accessible_attrs.include?(key) or accessible_attrs.include?(key.to_s))
|
87
87
|
modified = true
|
88
88
|
instance.send("#{key}=", value)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modelfactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Balthrop
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2009-05-08 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.
|
24
|
+
version: 1.12.2
|
25
25
|
version:
|
26
26
|
description: A replacement for fixtures.
|
27
27
|
email: justin@geni.com
|