Module: Backbonify::Generators::ResourceHelpers
- Included in:
- HbsGenerator, InstallGenerator, ModelGenerator, RouterGenerator, ScaffoldGenerator, ViewsGenerator
- Defined in:
- lib/generators/backbonify/resource_helpers.rb
Instance Method Summary collapse
-
#application_name ⇒ Object
TODO : Add an option so “App” is default.
- #backbone_path ⇒ Object
-
#collection_namespace ⇒ Object
> Perf.Collections.Performances.
- #js_app_name ⇒ Object
- #jst(action) ⇒ Object
-
#model_namespace ⇒ Object
> Perf.Models.Performance.
-
#plural_model_name ⇒ Object
> performances.
-
#router_namespace ⇒ Object
> Perf.Routers.Performances.
-
#singular_model_name ⇒ Object
> performance.
-
#uncapitalize(str) ⇒ Object
uncapitalize(“ABC”) => aBC.
-
#view_namespace ⇒ Object
> Perf.Views.Performances.
Instance Method Details
#application_name ⇒ Object
TODO : Add an option so “App” is default
48 49 50 51 52 53 54 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 48 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/backbonify/resource_helpers.rb', line 5 def backbone_path "app/assets/javascripts" end |
#collection_namespace ⇒ Object
> Perf.Collections.Performances
25 26 27 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 25 def collection_namespace [js_app_name, "Collections", plural_name.camelize].join(".") end |
#js_app_name ⇒ Object
43 44 45 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 43 def js_app_name application_name.camelize end |
#jst(action) ⇒ Object
39 40 41 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 39 def jst(action) "templates/#{plural_name}/#{action}" end |
#model_namespace ⇒ Object
> Perf.Models.Performance
10 11 12 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 10 def model_namespace [js_app_name, "Models", class_name].join(".") end |
#plural_model_name ⇒ Object
> performances
20 21 22 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 20 def plural_model_name uncapitalize(plural_name.camelize) end |
#router_namespace ⇒ Object
> Perf.Routers.Performances
35 36 37 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 35 def router_namespace [js_app_name, "Routers", plural_name.camelize].join(".") end |
#singular_model_name ⇒ Object
> performance
15 16 17 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 15 def singular_model_name uncapitalize singular_name.camelize end |
#uncapitalize(str) ⇒ Object
uncapitalize(“ABC”) => aBC
57 58 59 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 57 def uncapitalize(str) str[0, 1].downcase << str[1..-1] end |
#view_namespace ⇒ Object
> Perf.Views.Performances
30 31 32 |
# File 'lib/generators/backbonify/resource_helpers.rb', line 30 def view_namespace [js_app_name, "Views", plural_name.camelize].join(".") end |