Module: Ice::GeneratedHelpers

Defined in:
lib/ice/generated_helpers.rb

Class Method Summary collapse

Class Method Details

.get_routesObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ice/generated_helpers.rb', line 3

def self.get_routes
  coffeescript = ""
  Ice::BaseCube.subclasses.map(&:name).each do |cube_model_name|
    model_name = cube_model_name.sub(/Cube/, "")
    name = model_name[0].downcase + model_name[1..-1]

    coffeescript << <<-COFFEESCRIPT

  edit#{model_name}Path = (object)->
    "/#{name.tableize}/" + object.id + "/edit"

  new#{model_name}Path = ()->
    "/#{name.tableize}/new"

  #{name}Path = (object)->
    "/#{name.tableize}/" + object.id

  #{name.pluralize}Path = ()->
    "/#{name.tableize}"

    COFFEESCRIPT
  end
  coffeescript
end