Class: Gloo::WebSvr::Routing::ResourceRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/web_svr/routing/resource_router.rb

Constant Summary collapse

INDEX =
'index'.freeze
SHOW =
'show'.freeze
DELETE =
'delete'.freeze
UPDATE =
'update'.freeze
POST_ROUTE =
'create'.freeze

Class Method Summary collapse

Class Method Details

.is_implicit_create?(method, route_segment) ⇒ Boolean

Is the given route segment an implicit create resource? It is explicit if it is ‘create’

and implicit if it is a POST to the resource.

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/gloo/web_svr/routing/resource_router.rb', line 25

def self.is_implicit_create?( method, route_segment )
  return false unless Gloo::WebSvr::WebMethod.is_post?( method )

  return ! route_segment.eql?( POST_ROUTE )
end

.segment_for_method(method) ⇒ Object

Add the segment based on the method.



34
35
36
37
38
39
40
41
42
# File 'lib/gloo/web_svr/routing/resource_router.rb', line 34

def self.segment_for_method( method ) 
  if Gloo::WebSvr::WebMethod.is_delete?( method )
    return DELETE
  elsif Gloo::WebSvr::WebMethod.is_patch?( method )
    return UPDATE
  else
    return SHOW
  end
end