Class: Apic::RouteWrapper

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/apic/route_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#endpointObject



23
24
25
# File 'lib/apic/route_wrapper.rb', line 23

def endpoint
  [verb, path].join(' ')
end

#internal?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/apic/route_wrapper.rb', line 27

def internal?
  requirements[:controller].to_s =~ %r{\Arails/(info|welcome)} ||
    path =~ %r{\A#{Rails.application.config.assets.prefix}} ||
    path =~ %r{\A\/apic}
end

#to_hObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/apic/route_wrapper.rb', line 6

def to_h
  endpoint = {
    path: path,
    parts: parts - [:format],
    verb: verb,
    template: template,
    key: key,
    authentication_required: authentication_required
  }

  if %(PATCH DELETE).include? verb
    endpoint[:template] << '_method'
  end

  endpoint
end