Sha256: 60fce6148184de30e02147573e1cf800be352160eade071f6d160a1e43a34f3b

Contents?: true

Size: 899 Bytes

Versions: 10

Compression:

Stored size: 899 Bytes

Contents

require 'rails/generators/base'
require 'generators/authenticate/helpers'

module Authenticate
  module Generators
    class RoutesGenerator < Rails::Generators::Base
      include Authenticate::Generators::Helpers

      source_root File.expand_path('../templates', __FILE__)

      def add_authenticate_routes
        route(authenticate_routes)
      end

      def disable_authenticate_internal_routes
        inject_into_file(
          'config/initializers/authenticate.rb',
          "  config.routes = false \n",
          after: "Authenticate.configure do |config|\n"
        )
      end

      private

      def authenticate_routes
        @user_model = Authenticate.configuration.user_model_route_key
        ERB.new(File.read(routes_file_path)).result(binding)
      end

      def routes_file_path
        File.expand_path(find_in_source_paths('routes.rb'))
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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