purzelrakete-restful 0.2.8 → 0.2.9
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.
@@ -73,7 +73,11 @@ module Restful
|
|
73
73
|
|
74
74
|
elsif self.is_a?(Hash)
|
75
75
|
elements = self.map do |k,v|
|
76
|
-
|
76
|
+
if v.respond_to?(:to_restful) and v.class.respond_to?(:restful_config)
|
77
|
+
value = Restful::Converters::ActiveRecord.convert(v, v.class.restful_config)
|
78
|
+
else
|
79
|
+
value = v.respond_to?(:to_restful) ? v.to_restful : v
|
80
|
+
end
|
77
81
|
Restful::ApiModel::Attribute.new(k, value, :map)
|
78
82
|
end
|
79
83
|
|
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.9"
|
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"
|
@@ -72,9 +72,23 @@ bloggs_da_pet_hater:
|
|
72
72
|
hash_with_person:
|
73
73
|
|
|
74
74
|
{
|
75
|
-
"total_hits":
|
75
|
+
"total_hits": 1,
|
76
76
|
"a_person": {
|
77
77
|
"restful_url": "http://example.com:3000/people/<%= @person.to_param %>",
|
78
78
|
"name": "Joe Bloggs"
|
79
79
|
}
|
80
|
+
}
|
81
|
+
|
82
|
+
hash_with_people:
|
83
|
+
|
|
84
|
+
{
|
85
|
+
"total_hits": 2,
|
86
|
+
"people": [{
|
87
|
+
"restful_url": "http://example.com:3000/people/<%= @person.to_param %>",
|
88
|
+
"name": "Joe Bloggs"
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"restful_url": "http://example.com:3000/people/<%= @person.to_param %>",
|
92
|
+
"name": "Joe Bloggs"
|
93
|
+
}]
|
80
94
|
}
|
@@ -26,7 +26,7 @@ context "restful publish" do
|
|
26
26
|
@pet = @person.pets.create(:name => "Mietze")
|
27
27
|
|
28
28
|
@pet.to_restful(:include => :owner).values.map(&:name).should.include :owner
|
29
|
-
Pet.restful_config.whitelisted.
|
29
|
+
Pet.restful_config.whitelisted.include?(:owner).should.equal false
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -72,6 +72,11 @@ context "json serializer" do
|
|
72
72
|
|
73
73
|
specify "should be able to serialize a map" do
|
74
74
|
Person.restful_publish(:name)
|
75
|
-
json_should_eql_fixture({ "total_hits" =>
|
75
|
+
json_should_eql_fixture({ "total_hits" => 1, "a_person" => @person }.to_restful_json, "people", :hash_with_person)
|
76
|
+
end
|
77
|
+
|
78
|
+
specify "should be able to serialize a map with arrays as values" do
|
79
|
+
Person.restful_publish(:name)
|
80
|
+
json_should_eql_fixture({ "total_hits" => 2, "people" => [ @person, @person ] }.to_restful_json, "people", :hash_with_people)
|
76
81
|
end
|
77
82
|
end
|