Class: Paloma::Utilities

Inherits:
Object
  • Object
show all
Defined in:
lib/paloma/utilities.rb

Class Method Summary collapse

Class Method Details

.get_resource(controller_path) ⇒ Object



4
5
6
# File 'lib/paloma/utilities.rb', line 4

def self.get_resource controller_path
  controller_path.split('/').map(&:titleize).join('/').gsub(' ', '')
end

.interpret_route(route_string = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/paloma/utilities.rb', line 9

def self.interpret_route route_string = nil
  raise 'Empty route cannot be interpreted' if route_string.blank?

  parts = route_string.split '#'

  resource = parts.first
  resource = resource.blank? ? nil : resource

  action = parts.length != 1 ? parts.last : nil

  {:resource => resource, :action => action}
end