module Roar::Hypermedia::ClassMethods
Public Instance Methods
link(options, &block)
click to toggle source
Declares a hypermedia link in the document.
Example:
link :self do "http://orders/#{id}" end
The block is executed in instance context, so you may call properties or other accessors. Note that you're free to put decider logic into link
blocks, too.
# File lib/roar/hypermedia.rb, line 88 def link(options, &block) heritage.record(:link, options, &block) links_dfn = create_links_definition! # this assures the links are rendered at the right position. options = {:rel => options} unless options.is_a?(::Hash) links_dfn.link_configs << [options, block] end
Private Instance Methods
create_links_definition!()
click to toggle source
Add a :links Definition to the representable_attrs so they get rendered/parsed.
# File lib/roar/hypermedia.rb, line 100 def create_links_definition! dfn = definitions["links"] and return dfn # only create it once. options = links_definition_options options.merge!(getter: ->(opts) { prepare_links!(opts) }) dfn = build_definition(:links, options) dfn.extend(DefinitionOptions) dfn end