Class: Docs::RoutesCollection::Item

Inherits:
Object
  • Object
show all
Defined in:
app/models/docs/routes_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route) ⇒ Item

Returns a new instance of Item.



27
28
29
30
31
32
33
# File 'app/models/docs/routes_collection.rb', line 27

def initialize(route)
  @path    = route.path.sub(/\(\.:format\)$/, '.json')
  @via     = route.verb
  @reqs    = route.reqs
  @pattern = route.json_regexp
  @controller, @action = reqs.split("#")
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



25
26
27
# File 'app/models/docs/routes_collection.rb', line 25

def action
  @action
end

#controllerObject

Returns the value of attribute controller.



25
26
27
# File 'app/models/docs/routes_collection.rb', line 25

def controller
  @controller
end

#pathObject

Returns the value of attribute path.



25
26
27
# File 'app/models/docs/routes_collection.rb', line 25

def path
  @path
end

#patternObject

Returns the value of attribute pattern.



25
26
27
# File 'app/models/docs/routes_collection.rb', line 25

def pattern
  @pattern
end

#reqsObject

Returns the value of attribute reqs.



25
26
27
# File 'app/models/docs/routes_collection.rb', line 25

def reqs
  @reqs
end

#viaObject

Returns the value of attribute via.



25
26
27
# File 'app/models/docs/routes_collection.rb', line 25

def via
  @via
end

Instance Method Details

#inspectObject



39
40
41
# File 'app/models/docs/routes_collection.rb', line 39

def inspect
  "#{via} #{path} => #{reqs}"
end

#to_page_attributesObject



35
36
37
# File 'app/models/docs/routes_collection.rb', line 35

def to_page_attributes
  { path: path, via: via, reqs: reqs, page_category_slug: controller[/^api\/(\w+)/, 1] }
end