roar 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.11.4
2
+
3
+ * Links can now return a hash of attributes as `link :self do {:href => fruit_path(self), :title => "Yummy stuff"} end`.
4
+
1
5
  ## 0.11.3
2
6
 
3
7
  * Fixed an installation issue under Windows.
@@ -20,6 +20,12 @@ module Roar
20
20
  # "http://orders/#{id}"
21
21
  # end
22
22
  #
23
+ # If you need dynamic attributes, the block can return a hash.
24
+ #
25
+ # link :preview do
26
+ # {:href => image.url, :title => image.name}
27
+ # end
28
+ #
23
29
  # Sometimes you need values from outside when the representation links are rendered. Just pass them
24
30
  # to the render method, they will be available as block parameters.
25
31
  #
@@ -53,8 +59,9 @@ module Roar
53
59
 
54
60
  links_def.rel2block.each do |config| # config is [{..}, block]
55
61
  options = config.first
56
- options[:href] = run_link_block(config.last, *args) or next
57
-
62
+ href = run_link_block(config.last, *args) or next
63
+ options.merge! href.is_a?(Hash) ? href : {:href => href}
64
+
58
65
  links.update_link(Feature::Hypermedia::Hyperlink.new(options))
59
66
  end
60
67
  end
@@ -36,12 +36,12 @@ module Roar::Representer
36
36
  module Resources
37
37
  # Write the property to the +_embedded+ hash when it's a resource.
38
38
  def compile_fragment(bin, doc)
39
- return super unless bin.definition.options[:embedded]
39
+ return super unless bin.options[:embedded]
40
40
  super(bin, doc[:_embedded] ||= {})
41
41
  end
42
42
 
43
43
  def uncompile_fragment(bin, doc)
44
- return super unless bin.definition.options[:embedded]
44
+ return super unless bin.options[:embedded]
45
45
  super(bin, doc["_embedded"] || {})
46
46
  end
47
47
  end
data/lib/roar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Roar
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
data/roar.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency "representable", ">= 1.2.2"
22
+ s.add_runtime_dependency "representable", ">= 1.2.8"
23
23
 
24
24
  s.add_development_dependency "rake"
25
25
  s.add_development_dependency "test_xml"
@@ -41,6 +41,16 @@ class HypermediaTest
41
41
 
42
42
  assert_equal "{\"links\":[{\"rel\":\"self\",\"href\":\"http://self/1\"}]}", Object.new.extend(@mod).to_json(:id => 1)
43
43
  end
44
+
45
+ it "supports returning hash" do
46
+ @mod.class_eval do
47
+ link :self do
48
+ {:href => "http://self", :type => "image/jpg"}
49
+ end
50
+ end
51
+
52
+ assert_equal "{\"links\":[{\"rel\":\"self\",\"href\":\"http://self\",\"type\":\"image/jpg\"}]}", Object.new.extend(@mod).to_json
53
+ end
44
54
  end
45
55
 
46
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000Z
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: representable
16
- requirement: &68886170 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2.2
21
+ version: 1.2.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *68886170
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.8
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &68885130 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *68885130
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: test_xml
38
- requirement: &68884080 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *68884080
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: minitest
49
- requirement: &68883670 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: 2.8.1
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *68883670
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.1
58
78
  description: Streamlines the development of RESTful, resource-oriented architectures
59
79
  in Ruby.
60
80
  email:
@@ -150,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
170
  version: '0'
151
171
  requirements: []
152
172
  rubyforge_project: roar
153
- rubygems_version: 1.8.10
173
+ rubygems_version: 1.8.24
154
174
  signing_key:
155
175
  specification_version: 3
156
176
  summary: Resource-oriented architectures in Ruby.