Module: Backbone::Generators::ResourceHelpers
- Included in:
- InstallGenerator, ModelGenerator, RouterGenerator
- Defined in:
- lib/generators/backbone/resource_helpers.rb
Instance Method Summary collapse
- #application_name ⇒ Object
- #backbone_path ⇒ Object
- #collection_namespace ⇒ Object
- #js_app_name ⇒ Object
- #jst(action) ⇒ Object
- #model_namespace ⇒ Object
- #plural_model_name ⇒ Object
- #router_namespace ⇒ Object
- #singular_model_name ⇒ Object
- #uncapitalize(str) ⇒ Object
- #view_namespace ⇒ Object
Instance Method Details
#application_name ⇒ Object
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_path ⇒ Object
5 6 7 |
# File 'lib/generators/backbone/resource_helpers.rb', line 5 def backbone_path "app/assets/javascripts/backbone" end |
#collection_namespace ⇒ Object
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_name ⇒ Object
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_namespace ⇒ Object
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_name ⇒ Object
17 18 19 |
# File 'lib/generators/backbone/resource_helpers.rb', line 17 def plural_model_name uncapitalize(plural_name.camelize) end |
#router_namespace ⇒ Object
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_name ⇒ Object
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_namespace ⇒ Object
25 26 27 |
# File 'lib/generators/backbone/resource_helpers.rb', line 25 def view_namespace [js_app_name, "Views", plural_name.camelize].join(".") end |