Sha256: 44aeaed2120eb713b0c7f9a4f42fb66048e3811dc6045a928ad25982d58c9c53

Contents?: true

Size: 1.27 KB

Versions: 10

Compression:

Stored size: 1.27 KB

Contents

module Authenticate
  module Generators
    module Helpers
      private

      # Either return the model passed in a classified form or return the default "User".
      def model_class_name
        options[:model] ? options[:model].classify : 'User'
      end

      def model_path
        @model_path ||= File.join('app', 'models', "#{file_path}.rb")
      end

      def file_path
        model_name.underscore
      end

      def namespace
        Rails::Generators.namespace if Rails::Generators.respond_to?(:namespace)
      end

      def namespaced?
        !namespace.nil?
      end

      def model_name
        if namespaced?
          [namespace.to_s] + [model_class_name]
        else
          [model_class_name]
        end.join('::')
      end

      def table_name
        @table_name ||= begin
          base = plural_name
          (class_path + [base]).join('_')
        end
      end

      def class_path
        @class_path
      end

      def singular_name
        @file_name
      end

      def plural_name
        singular_name.pluralize
      end

      def assign_names!(name) #:nodoc:
        @class_path = name.include?('/') ? name.split('/') : name.split('::')
        @class_path.map!(&:underscore)
        @file_name = @class_path.pop
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authenticate-0.7.3 lib/generators/authenticate/helpers.rb
authenticate-0.7.2 lib/generators/authenticate/helpers.rb
authenticate-0.7.1 lib/generators/authenticate/helpers.rb
authenticate-0.7.0 lib/generators/authenticate/helpers.rb
authenticate-0.6.1 lib/generators/authenticate/helpers.rb
authenticate-0.6.0 lib/generators/authenticate/helpers.rb
authenticate-0.5.0 lib/generators/authenticate/helpers.rb
authenticate-0.4.0 lib/generators/authenticate/helpers.rb
authenticate-0.3.3 lib/generators/authenticate/helpers.rb
authenticate-0.3.2 lib/generators/authenticate/helpers.rb