Module: Backbone::Generators::ResourceHelpers

Included in:
InstallGenerator, ModelGenerator, RouterGenerator
Defined in:
lib/generators/backbone/resource_helpers.rb

Instance Method Summary collapse

Instance Method Details

#application_nameObject



41
42
43
44
45
46
47
# File 'lib/generators/backbone/resource_helpers.rb', line 41

def application_name
  if defined?(Rails) && Rails.application
    Rails.application.class.name.split('::').first
  else
    "application"
  end
end

#backbone_pathObject



5
6
7
# File 'lib/generators/backbone/resource_helpers.rb', line 5

def backbone_path
  "app/assets/javascripts/backbone"
end

#collection_namespaceObject



21
22
23
# File 'lib/generators/backbone/resource_helpers.rb', line 21

def collection_namespace
  [js_app_name, "Collections", plural_name.camelize].join(".")
end

#js_app_nameObject



37
38
39
# File 'lib/generators/backbone/resource_helpers.rb', line 37

def js_app_name
  application_name.camelize
end

#jst(action) ⇒ Object



33
34
35
# File 'lib/generators/backbone/resource_helpers.rb', line 33

def jst(action)
  "backbone/templates/#{plural_name}/#{action}"
end

#model_namespaceObject



9
10
11
# File 'lib/generators/backbone/resource_helpers.rb', line 9

def model_namespace
  [js_app_name, "Models", class_name].join(".")
end

#plural_model_nameObject



17
18
19
# File 'lib/generators/backbone/resource_helpers.rb', line 17

def plural_model_name
  uncapitalize(plural_name.camelize)
end

#router_namespaceObject



29
30
31
# File 'lib/generators/backbone/resource_helpers.rb', line 29

def router_namespace
  [js_app_name, "Routers", plural_name.camelize].join(".")
end

#singular_model_nameObject



13
14
15
# File 'lib/generators/backbone/resource_helpers.rb', line 13

def singular_model_name
  uncapitalize singular_name.camelize
end

#uncapitalize(str) ⇒ Object



49
50
51
# File 'lib/generators/backbone/resource_helpers.rb', line 49

def uncapitalize(str)
    str[0, 1].downcase + str[1..-1]
end

#view_namespaceObject



25
26
27
# File 'lib/generators/backbone/resource_helpers.rb', line 25

def view_namespace
  [js_app_name, "Views", plural_name.camelize].join(".")
end