Class: Ground::State

Inherits:
Activity
  • Object
show all
Includes:
Protocol::Render, Protocol::Render::Template
Defined in:
lib/ground/activity/state.rb

Class Method Summary collapse

Methods included from Protocol::Render::Template

#erb, #haml, #plain, #slim

Methods included from Protocol::Render

#forbid, #html, #json, #non_found, #not_accept, #redirect, #text, #unauthorized, #xml

Class Method Details

.detect_route(verb) ⇒ Object



24
25
26
# File 'lib/ground/activity/state.rb', line 24

def detect_route(verb)
  Ridge.routes[verb.to_s.upcase].detect {|route| route[1] == self}
end

.path(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ground/activity/state.rb', line 12

def path(*args)
  paths = []
  route = detect_route('GET') || detect_route('POST')
  
  route[0].split('/').each_with_index {|route_seg, index|
    paths[index] = (route_seg =~ /^:\w+/ ? args.shift : route_seg)
  }
  paths << '/' if paths.size == 0
  paths.join('/')
  
end