module ReSorcery::Linked
Public Class Methods
included(base)
click to toggle source
# File lib/re_sorcery/linked.rb, line 41 def self.included(base) base.extend(ClassMethods) end
link_class()
click to toggle source
# File lib/re_sorcery/linked.rb, line 45 def self.link_class @link_class ||= LinkClassFactory.make_link_class end
Public Instance Methods
links()
click to toggle source
# File lib/re_sorcery/linked.rb, line 49 def links instance_exec(&self.class.instance_exec { @links_proc ||= -> {} }) created_links = (@_created_links ||= []) @_created_links = [] # Clear out so `links` can run cleanly next time created_links.each_with_index.inject(ok([])) do |result_array, (link_result, index)| result_array.and_then do |ok_array| link_result .map { |link| ok_array << link } .map_error { |error| "Error with Link at index #{index}: #{error}" } end end end
Private Instance Methods
link(rel, href, method = 'get', type = 'application/json')
click to toggle source
Define a ‘Link` for an object
@see ‘ReSorcery::Linked::Link#initialize` for param types
# File lib/re_sorcery/linked.rb, line 68 def link(rel, href, method = 'get', type = 'application/json') klass = Linked.link_class (@_created_links ||= []) << klass.new(rel: rel, href: href, method: method, type: type).fields end