Module: Roar::Representer::JSON::HAL::Links::ClassMethods
- Defined in:
- lib/roar/representer/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
214 215 216 |
# File 'lib/roar/representer/json/hal.rb', line 214 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
200 201 202 203 204 |
# File 'lib/roar/representer/json/hal.rb', line 200 def links(, &block) = {:rel => } if .is_a?(Symbol) [:array] = true # FIXME: we need to save this information somewhere. link(, &block) end |
#links_definition_options ⇒ Object
184 185 186 187 188 189 190 191 192 |
# File 'lib/roar/representer/json/hal.rb', line 184 def [:links, { :extend => HAL::Links::LinkCollectionRepresenter, :instance => lambda { |*| LinkCollection.new(link_array_rels) }, # defined in InstanceMethods as this is executed in represented context. :decorator_scope => true } ] end |