Sha256: 50dff641ea75dd94db27148d475b2e668cdba7145204039d8f057e8d75332ace

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

module Backbone
  module Generators
    module Helpers
      
      def backbone_path
        "app/assets/javascripts/backbone"
      end
      
      def model_namespace
        [js_app_name, "Models", class_name].join(".")
      end
      
      def singular_model_name
        uncapitalize singular_name.camelize
      end
      
      def plural_model_name
        uncapitalize(plural_name.camelize)
      end
      
      def collection_namespace
        [js_app_name, "Collections", plural_name.camelize].join(".")
      end
      
      def view_namespace
        [js_app_name, "Views", plural_name.camelize].join(".")
      end
      
      def router_namespace
        [js_app_name, "Routers", plural_name.camelize].join(".")
      end
      
      def jst(action)
        "backbone/templates/#{plural_name}/#{action}"
      end
      
      def js_app_name
        application_name.camelize
      end
      
      def application_name
        if defined?(Rails) && Rails.application
          Rails.application.class.name.split('::').first
        else
          "application"
        end
      end
      
      def uncapitalize(str)
        str[0, 1].downcase << str[1..-1]
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
railsy_backbone-0.0.5 lib/generators/backbone/helpers.rb
railsy_backbone-0.0.4 lib/generators/backbone/helpers.rb
railsy_backbone-0.0.3 lib/generators/backbone/helpers.rb
railsy_backbone-0.0.2 lib/generators/backbone/helpers.rb