Sha256: 41b8018c59515b38df8de6edfdfeb2c4bb042430c9c614f0d3d7b05351515b38

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Protected
  module Generators
    # Include this module in your generator to generate Devise views.
    # `copy_views` is the main method and by default copies all views
    # with forms.
    module ViewPathTemplates #:nodoc:
      extend ActiveSupport::Concern

      included do
        argument :scope, :required => false, :default => nil,
                         :desc => "The scope to copy views to"

        public_task :copy_views
      end

      def copy_views
        view_directory :passwords
        view_directory :sessions
        view_directory "../user_mailer"
        view_directory :users
      end

      protected

      def view_directory(name, _target_path = nil)
        directory name.to_s, _target_path || "#{target_path}/#{name}"
      end

      def target_path
        @target_path ||= "app/views/#{scope || :protected}"
      end
    end

    class ViewsGenerator < Rails::Generators::Base #:nodoc:
      include ViewPathTemplates
      source_root File.expand_path("../../../../../app/views/protected", __FILE__)
      desc "Copies default Protected views to your application."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protected-1.0.4 lib/generators/protected/views/views_generator.rb