Class: Shaf::Yard::LinkMethodHandler

Inherits:
BaseMethodHandler show all
Defined in:
lib/shaf/yard/link_method_handler.rb

Overview

Handles call to Shaf::Serializer::link

Instance Method Summary collapse

Methods inherited from BaseMethodHandler

#process, #serializer_namespace

Instance Method Details

#curieObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/shaf/yard/link_method_handler.rb', line 23

def curie
  m = name.match(/([^:]+):/)
  return m[1] if m

  statement.parameters(false).each do |param|
    next unless param&.respond_to? :source

    str = String(param.source)
    m = str.match(/curie:\s:?(\w+)/)
    return m[1] if m
  end

  nil
end

#nameObject



19
20
21
# File 'lib/shaf/yard/link_method_handler.rb', line 19

def name
  super.sub(/[^:]+:/, '')
end

#objectObject



11
12
13
14
15
16
17
# File 'lib/shaf/yard/link_method_handler.rb', line 11

def object
  LinkObject.new(serializer_namespace, name).tap do |link|
    link.dynamic = true
    link.rel = name
    link.curie = curie
  end
end