Module: Roar::Hypermedia::ClassMethods

Defined in:
lib/roar/hypermedia.rb

Instance Method Summary collapse

Instance Method Details

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.


88
89
90
91
92
93
94
95
96
# 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