kelredd-resourceful 0.7.14 → 0.7.16
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -16,8 +16,8 @@ module Resourceful
|
|
16
16
|
raise ArgumentError, "has_many_resourceful requires a :class_name option to be specified" unless config[:class_name]
|
17
17
|
class_name = config.delete(:class_name).to_s
|
18
18
|
find_method_name = (config.delete(:method) || 'find').to_s
|
19
|
-
force = config.delete(:force) ||
|
20
|
-
define_method(name) do
|
19
|
+
force = config.delete(:force) || false
|
20
|
+
define_method(name, reload=false) do
|
21
21
|
klass = class_name.resourceful_constantize
|
22
22
|
raise ArgumentError, "has_many_resourceful :class_name '#{class_name}' is not defined" if klass.nil?
|
23
23
|
unless klass.respond_to?(find_method_name)
|
@@ -26,10 +26,11 @@ module Resourceful
|
|
26
26
|
fk = config.delete(:foreign_key) || "#{self.class.name.demodulize.underscore}_id"
|
27
27
|
fk_method = config.delete(:foreign_key_method) || 'id'
|
28
28
|
config[fk] = self.send(fk_method)
|
29
|
-
instance_variable_get("@#{clean_name}")
|
30
|
-
instance_variable_set("@#{clean_name}",
|
31
|
-
|
32
|
-
|
29
|
+
if reload || (assoc_val = instance_variable_get("@#{clean_name}")).nil?
|
30
|
+
instance_variable_set("@#{clean_name}", klass.send(find_method_name, :all, config, force))
|
31
|
+
else
|
32
|
+
assoc_val
|
33
|
+
end
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -40,8 +41,8 @@ module Resourceful
|
|
40
41
|
class_name = config.delete(:class_name).to_s
|
41
42
|
foreign_key = config.delete(:foreign_key) || "#{clean_name}_id"
|
42
43
|
find_method_name = (config.delete(:method) || 'find').to_s
|
43
|
-
force = config.delete(:force) ||
|
44
|
-
define_method(name) do
|
44
|
+
force = config.delete(:force) || false
|
45
|
+
define_method(name, reload=false) do
|
45
46
|
klass = class_name.resourceful_constantize
|
46
47
|
raise ArgumentError, "belongs_to_resourceful :class_name '#{class_name}' is not defined" if klass.nil?
|
47
48
|
unless self.respond_to?(foreign_key)
|
@@ -54,10 +55,11 @@ module Resourceful
|
|
54
55
|
if fk.nil? || (fk.respond_to?('empty?') && fk.empty?)
|
55
56
|
nil
|
56
57
|
else
|
57
|
-
instance_variable_get("@#{clean_name}")
|
58
|
-
instance_variable_set("@#{clean_name}",
|
59
|
-
|
60
|
-
|
58
|
+
if reload || (assoc_val = instance_variable_get("@#{clean_name}")).nil?
|
59
|
+
instance_variable_set("@#{clean_name}", klass.send(find_method_name, fk, config, force))
|
60
|
+
else
|
61
|
+
assoc_val
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
@@ -16,8 +16,8 @@ module Resourceful
|
|
16
16
|
raise ArgumentError, "has_many requires a :class option to be specified" unless config[:class]
|
17
17
|
class_name = config.delete(:class).to_s
|
18
18
|
find_method_name = (config.delete(:method) || 'find').to_s
|
19
|
-
force = config.delete(:force) ||
|
20
|
-
define_method(name) do
|
19
|
+
force = config.delete(:force) || false
|
20
|
+
define_method(name, reload=false) do
|
21
21
|
klass = self.class.get_namespaced_klass(class_name)
|
22
22
|
raise ArgumentError, "has_many :class '#{class_name}' is not defined in any given namespaces" if klass.nil?
|
23
23
|
unless klass.respond_to?(find_method_name)
|
@@ -26,10 +26,11 @@ module Resourceful
|
|
26
26
|
fk = config.delete(:foreign_key) || "#{self.class.name.demodulize.underscore}_id"
|
27
27
|
fk_method = config.delete(:foreign_key_method) || 'id'
|
28
28
|
config[fk] = self.send(fk_method)
|
29
|
-
instance_variable_get("@#{clean_name}")
|
30
|
-
instance_variable_set("@#{clean_name}",
|
31
|
-
|
32
|
-
|
29
|
+
if reload || (assoc_val = instance_variable_get("@#{clean_name}")).nil?
|
30
|
+
instance_variable_set("@#{clean_name}", klass.send(find_method_name, :all, config, force))
|
31
|
+
else
|
32
|
+
assoc_val
|
33
|
+
end
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -40,8 +41,8 @@ module Resourceful
|
|
40
41
|
class_name = config.delete(:class).to_s
|
41
42
|
foreign_key = config.delete(:foreign_key) || "#{clean_name}_id"
|
42
43
|
find_method_name = (config.delete(:method) || 'find').to_s
|
43
|
-
force = config.delete(:force) ||
|
44
|
-
define_method(name) do
|
44
|
+
force = config.delete(:force) || false
|
45
|
+
define_method(name, reload=false) do
|
45
46
|
klass = self.class.get_namespaced_klass(class_name)
|
46
47
|
raise ArgumentError, "belongs_to :class '#{class_name}' is not defined in any given namespaces" if klass.nil?
|
47
48
|
unless self.respond_to?(foreign_key)
|
@@ -54,10 +55,11 @@ module Resourceful
|
|
54
55
|
if fk.nil? || (fk.respond_to?('empty?') && fk.empty?)
|
55
56
|
nil
|
56
57
|
else
|
57
|
-
instance_variable_get("@#{clean_name}")
|
58
|
-
instance_variable_set("@#{clean_name}",
|
59
|
-
|
60
|
-
|
58
|
+
if reload || (assoc_val = instance_variable_get("@#{clean_name}")).nil?
|
59
|
+
instance_variable_set("@#{clean_name}", klass.send(find_method_name, fk, config, force))
|
60
|
+
else
|
61
|
+
assoc_val
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
data/lib/resourceful/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelredd-resourceful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-01 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -83,15 +83,12 @@ extra_rdoc_files:
|
|
83
83
|
files:
|
84
84
|
- README.rdoc
|
85
85
|
- Rakefile
|
86
|
-
- lib/resourceful
|
87
|
-
- lib/resourceful/agent
|
88
86
|
- lib/resourceful/agent/base.rb
|
89
87
|
- lib/resourceful/agent/mechanize.rb
|
90
88
|
- lib/resourceful/agent/rest_client.rb
|
91
89
|
- lib/resourceful/agent.rb
|
92
90
|
- lib/resourceful/exceptions.rb
|
93
91
|
- lib/resourceful/extensions.rb
|
94
|
-
- lib/resourceful/model
|
95
92
|
- lib/resourceful/model/activerecord_associations.rb
|
96
93
|
- lib/resourceful/model/attribute_types.rb
|
97
94
|
- lib/resourceful/model/base.rb
|
@@ -101,18 +98,17 @@ files:
|
|
101
98
|
- lib/resourceful/model/json.rb
|
102
99
|
- lib/resourceful/model/xml.rb
|
103
100
|
- lib/resourceful/model.rb
|
104
|
-
- lib/resourceful/resource
|
105
101
|
- lib/resourceful/resource/cache.rb
|
106
102
|
- lib/resourceful/resource/format.rb
|
107
103
|
- lib/resourceful/resource.rb
|
108
|
-
- lib/resourceful/shoulda
|
109
104
|
- lib/resourceful/shoulda/test_unit.rb
|
110
105
|
- lib/resourceful/shoulda.rb
|
111
106
|
- lib/resourceful/version.rb
|
112
107
|
- lib/resourceful.rb
|
113
|
-
has_rdoc:
|
108
|
+
has_rdoc: true
|
114
109
|
homepage: ""
|
115
|
-
licenses:
|
110
|
+
licenses: []
|
111
|
+
|
116
112
|
post_install_message:
|
117
113
|
rdoc_options:
|
118
114
|
- --main
|