Sha256: 597d78b3175a26f308282227707e1ba2a5df18073376f848d7e87a2ba700cb7a

Contents?: true

Size: 870 Bytes

Versions: 7

Compression:

Stored size: 870 Bytes

Contents

module Trestle
  module Auth
    module Generators
      class AdminGenerator < ::Rails::Generators::Base
        desc "Creates a Trestle admin for managing Administrators"

        argument :model, type: :string, default: "Administrator"

        class_option :devise, type: :boolean, default: false, desc: "Create admin for a Devise user model"

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

        def create_admin
          template "admin.rb.erb", File.join('app/admin/auth', "#{model.underscore.pluralize}_admin.rb")
        end

        def devise?
          options[:devise]
        end

      protected
        def parameter_name
          singular_name
        end

        def plural_name
          singular_name.pluralize
        end

        def singular_name
          model.demodulize.underscore
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
trestle-auth-0.5.0 lib/generators/trestle/auth/admin/admin_generator.rb
trestle-auth-0.5.0.pre2 lib/generators/trestle/auth/admin/admin_generator.rb
trestle-auth-0.5.0.pre lib/generators/trestle/auth/admin/admin_generator.rb
trestle-auth-0.4.4 lib/generators/trestle/auth/admin/admin_generator.rb
trestle-auth-0.4.3 lib/generators/trestle/auth/admin/admin_generator.rb
trestle-auth-0.4.2 lib/generators/trestle/auth/admin/admin_generator.rb
trestle-auth-0.4.1 lib/generators/trestle/auth/admin/admin_generator.rb