purzelrakete-restful 0.2.11 → 0.2.12
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/CHANGES.markdown +2 -2
- data/lib/restful/converters/active_record.rb +3 -5
- data/lib/restful/rails/active_record/configuration.rb +1 -1
- data/lib/restful/rails/active_record/metadata_tools.rb +9 -7
- data/restful.gemspec +2 -2
- data/test/converters/active_record_converter_test.rb +6 -3
- metadata +1 -1
data/CHANGES.markdown
CHANGED
@@ -7,6 +7,6 @@
|
|
7
7
|
* fixed issue where configurations where overwriting each other.
|
8
8
|
* added hash#to_restful
|
9
9
|
|
10
|
-
19. Aug 2009 - 0.2.
|
10
|
+
19. Aug 2009 - 0.2.12
|
11
11
|
|
12
|
-
* added ability to publish :wallet-restful-url (explicitly collapsed)
|
12
|
+
* added ability to publish :wallet-restful-url (explicitly collapsed)
|
@@ -24,10 +24,9 @@ module Restful
|
|
24
24
|
convert_to_simple_attribute(key, value, config, published, model)
|
25
25
|
end.compact
|
26
26
|
|
27
|
-
# has_many, has_one
|
27
|
+
# has_many, has_one, belongs_to
|
28
28
|
resource.values += model.class.reflections.keys.map do |key|
|
29
29
|
explicit_link = !!explicit_links.include?(key)
|
30
|
-
|
31
30
|
if config.published?(key.to_sym) || explicit_link
|
32
31
|
|
33
32
|
nested_config = config.nested(key.to_sym)
|
@@ -38,7 +37,6 @@ module Restful
|
|
38
37
|
Restful.collection(key, resources, extended_type)
|
39
38
|
end
|
40
39
|
elsif has_one?(model, key) or belongs_to?(model, key)
|
41
|
-
|
42
40
|
if config.expanded?(key, nested) && !explicit_link
|
43
41
|
convert_to_collection(model, key, nested_config, published) do |key, resources, extended_type|
|
44
42
|
returning(resources.first) do |res|
|
@@ -67,10 +65,10 @@ module Restful
|
|
67
65
|
|
68
66
|
# public methods
|
69
67
|
resource.values += (model.public_methods - Restful::Rails.tools.simple_attributes_on(model).keys.map(&:to_s)).map do |method_name|
|
70
|
-
|
68
|
+
|
71
69
|
explicit_link = !!explicit_links.include?(method_name.to_sym)
|
72
70
|
|
73
|
-
if
|
71
|
+
if !published.include?(method_name.to_sym) && (config.published?(method_name.to_sym) || explicit_link)
|
74
72
|
value = model.send(method_name.to_sym)
|
75
73
|
sanitized_method_name = method_name.tr("!?", "").tr("_", "-").to_sym
|
76
74
|
|
@@ -91,7 +91,7 @@ module Restful
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# FIXME: read Restful::Serializers::Base.serializers. Load order problems?
|
94
|
-
[:
|
94
|
+
[:atom_like, :hash, :json, :params, :xml].each do |format|
|
95
95
|
define_method("to_restful_#{ format }") do |*args|
|
96
96
|
self.to_restful(*args).serialize(format)
|
97
97
|
end
|
@@ -54,14 +54,16 @@ module Restful
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def self.dereference(url)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
if url
|
58
|
+
regexp = Regexp.new("#{ Restful::Rails.api_hostname }\/(.*)\/(.*)")
|
59
|
+
m, resource, params = *url.match(regexp)
|
60
|
+
resource = if resource && params
|
61
|
+
clazz = resource.try(:singularize).try(:camelize).try(:constantize)
|
62
|
+
clazz.find_by_restful(params) if clazz
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
+
resource.id if resource
|
66
|
+
end
|
65
67
|
end
|
66
68
|
|
67
69
|
# retruns non association / collection attributes.
|
data/restful.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "restful"
|
3
|
-
s.version = "0.2.
|
3
|
+
s.version = "0.2.12"
|
4
4
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
5
5
|
s.authors = ["Daniel Bornkessel", "Rany Keddo"]
|
6
6
|
s.date = "2009-08-11"
|
@@ -14,4 +14,4 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.requirements = %w{ brianmario-yajl-ruby }
|
15
15
|
s.rubygems_version = "1.3.1"
|
16
16
|
s.summary = "api niceness. "
|
17
|
-
end
|
17
|
+
end
|
@@ -18,13 +18,16 @@ context "active record converter" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
specify "should publish link and not resource when :oldest_pet_restful_url, where oldest_pet is a defined method" do
|
21
|
-
Person.restful_publish(:oldest_pet_restful_url)
|
22
|
-
@person.to_restful.links.should
|
21
|
+
Person.restful_publish(:oldest_pet_restful_url)
|
22
|
+
@person.to_restful.links.size.should.== 1
|
23
|
+
@person.to_restful.links.first.name.should.== "oldest-pet-restful-url"
|
23
24
|
end
|
24
25
|
|
25
26
|
specify "should publish link and not a nested resource with :wallet_restful_url" do
|
26
27
|
Person.restful_publish(:wallet_restful_url)
|
27
|
-
@person.to_restful.links.should
|
28
|
+
@person.to_restful.links.size.should.== 1
|
29
|
+
@person.to_restful.links.first.name.should.== "wallet-restful-url"
|
30
|
+
@person.to_restful.links.first.value.should.== @wallet.restful_url
|
28
31
|
end
|
29
32
|
|
30
33
|
specify "should be able to force expansion. force expanded attributes can never be collapsed. " do
|