Module: Roar::JSON::HAL::Links::ClassMethods
- Defined in:
- lib/roar/json/hal.rb
Instance Method Summary collapse
-
#curies(&block) ⇒ Object
Add a CURIEs link section as defined in.
-
#links(options, &block) ⇒ Object
Use this to define link arrays.
- #links_definition_options ⇒ Object
Instance Method Details
#curies(&block) ⇒ Object
Add a CURIEs link section as defined in
curies do
[{:name => :doc,
:href => "//docs/{rel}",
:templated => true}
]
end
188 189 190 |
# File 'lib/roar/json/hal.rb', line 188 def curies(&block) links(:curies, &block) end |
#links(options, &block) ⇒ Object
Use this to define link arrays. It accepts the shared rel attribute and an array of options per link object.
links :self do
[{:lang => "en", :href => "http://en.hit"},
{:lang => "de", :href => "http://de.hit"}]
end
174 175 176 177 178 |
# File 'lib/roar/json/hal.rb', line 174 def links(, &block) = {:rel => } if .is_a?(Symbol) || .is_a?(String) [:array] = true link(, &block) end |
#links_definition_options ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/roar/json/hal.rb', line 158 def { # collection: false, :as => :_links, decorator: Links::Representer, instance: ->(*) { Array.new }, # defined in InstanceMethods as this is executed in represented context. :exec_context => :decorator, } end |