Class: Shaf::Responder::Hal
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#controller, #options, #resource
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#build_response, call, #initialize, mime_type, #preload_links, use_as_default!
Constructor Details
This class inherits a constructor from Shaf::Responder::Base
Class Method Details
Instance Method Details
#body ⇒ Object
17 18 19 |
# File 'lib/shaf/responder/hal.rb', line 17 def body @body ||= generate_json end |
#lookup_rel(rel, response) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shaf/responder/hal.rb', line 21 def lookup_rel(rel, response) hal = response.serialized_hash links = hal&.dig(:_links, rel.to_sym) return [] unless links links = [links] unless links.is_a? Array links.map do |link| { href: link[:href], as: 'fetch', crossorigin: 'anonymous' } end end |