roar 0.11.6 → 0.11.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.markdown +4 -0
- data/lib/roar/representer/feature/hypermedia.rb +14 -15
- data/lib/roar/representer/json.rb +0 -3
- data/lib/roar/representer/xml.rb +0 -4
- data/lib/roar/version.rb +1 -1
- data/test/hypermedia_test.rb +1 -1
- metadata +1 -1
data/CHANGES.markdown
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.11.7
|
2
|
+
|
3
|
+
* Maintenance release: Fixing the horrible bug fix from 0.11.6 and make it a bit less horrible.
|
4
|
+
|
1
5
|
## 0.11.6
|
2
6
|
|
3
7
|
* "Fixing" a bug where `links_definition_option` was missing when no link was set in a representer. Note that this is a quick and horrible bugfix and will soon be cleaned up.
|
@@ -39,20 +39,6 @@ module Roar
|
|
39
39
|
base.extend ClassMethods
|
40
40
|
end
|
41
41
|
|
42
|
-
# TODO: the whole declarative setup in representable should happen on instance level so we don't need to share methods between class and instance.
|
43
|
-
module LinksDefinitionMethods
|
44
|
-
private
|
45
|
-
def create_links_definition
|
46
|
-
representable_attrs << links = LinksDefinition.new(*links_definition_options)
|
47
|
-
links
|
48
|
-
end
|
49
|
-
|
50
|
-
def links_definition
|
51
|
-
representable_attrs.find { |d| d.is_a?(LinksDefinition) } or create_links_definition
|
52
|
-
end
|
53
|
-
end
|
54
|
-
include LinksDefinitionMethods
|
55
|
-
|
56
42
|
def before_serialize(options={})
|
57
43
|
prepare_links!(options) unless options[:links] == false # DISCUSS: doesn't work when links are already setup (e.g. from #deserialize).
|
58
44
|
super # Representer::Base
|
@@ -77,6 +63,10 @@ module Roar
|
|
77
63
|
end
|
78
64
|
|
79
65
|
private
|
66
|
+
def links_definition
|
67
|
+
representable_attrs.find { |d| d.is_a?(LinksDefinition) } or [] # FIXME: this is a bug as soon as #links_definition is used somewhere else beside #prepare_links.
|
68
|
+
end
|
69
|
+
|
80
70
|
# Setup hypermedia links by invoking their blocks. Usually called by #serialize.
|
81
71
|
def prepare_links!(*args)
|
82
72
|
links_definition.each do |config| # config is [{..}, block]
|
@@ -110,7 +100,6 @@ module Roar
|
|
110
100
|
|
111
101
|
|
112
102
|
module ClassMethods
|
113
|
-
include LinksDefinitionMethods
|
114
103
|
# Declares a hypermedia link in the document.
|
115
104
|
#
|
116
105
|
# Example:
|
@@ -125,6 +114,16 @@ module Roar
|
|
125
114
|
options = {:rel => options} if options.is_a?(Symbol)
|
126
115
|
links_definition << [options, block]
|
127
116
|
end
|
117
|
+
|
118
|
+
private
|
119
|
+
def create_links_definition
|
120
|
+
representable_attrs << links = LinksDefinition.new(*links_definition_options)
|
121
|
+
links
|
122
|
+
end
|
123
|
+
|
124
|
+
def links_definition
|
125
|
+
representable_attrs.find { |d| d.is_a?(LinksDefinition) } or create_links_definition
|
126
|
+
end
|
128
127
|
end
|
129
128
|
|
130
129
|
|
@@ -49,9 +49,6 @@ module Roar
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def links_definition_options # FIXME: remove me ASAP!
|
53
|
-
[:links_array, {:from => :links, :class => Feature::Hypermedia::Hyperlink, :extend => HyperlinkRepresenter, :collection => true}]
|
54
|
-
end
|
55
52
|
|
56
53
|
require "representable/json/hash"
|
57
54
|
# Represents a hyperlink in standard roar+json hash representation.
|
data/lib/roar/representer/xml.rb
CHANGED
@@ -47,10 +47,6 @@ module Roar
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def links_definition_options # FIXME: remove me ASAP!
|
51
|
-
[:links_array, {:from => :link, :class => Feature::Hypermedia::Hyperlink, :collection => true, :extend => XML::HyperlinkRepresenter}]
|
52
|
-
end
|
53
|
-
|
54
50
|
|
55
51
|
require 'representable/xml/hash'
|
56
52
|
module HyperlinkRepresenter
|
data/lib/roar/version.rb
CHANGED
data/test/hypermedia_test.rb
CHANGED