Module: YARD::Templates::Helpers::BaseHelper

Defined in:
lib/yard-api/templates/helpers/base_helper.rb

Instance Method Summary collapse

Instance Method Details

#api_optionsObject



4
5
6
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 4

def api_options()
  YARD::APIPlugin.options
end

#get_current_routeObject



39
40
41
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 39

def get_current_route
  get_current_routes.first
end

#get_current_routesObject



35
36
37
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 35

def get_current_routes
  YARD::Templates::Helpers::RouteHelper.routes_for_yard_object(object)
end

#loggerObject



47
48
49
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 47

def logger
  YARD::APIPlugin.logger
end

#lookup_appendix(title) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 8

def lookup_appendix(title)
  appendix = nil

  logger.debug("Looking up appendix: #{title}")

  if object
    # try in the object scope
    appendix = YARD::Registry.at(".appendix.#{object.path}.#{title}")

    # try in the object's namespace scope
    if appendix.nil? && object.respond_to?(:namespace)
      appendix = YARD::Registry.at(".appendix.#{object.namespace.path}.#{title}")
    end
  end

  appendix
end

#schema_is_model?(schema) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 43

def schema_is_model?(schema)
  schema.has_key?('description') && schema.has_key?('properties')
end

#tag_partial(name, tag, locals = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/yard-api/templates/helpers/base_helper.rb', line 26

def tag_partial(name, tag, locals={})
  options[:tag] = tag
  locals.each_pair { |key, value| options[key] = value }
  out = erb(name)
  options.delete(:tag)
  locals.keys.each { |key| options.delete(key.to_sym) }
  out
end