Sha256: 945aeb50c82bea0f690ce7e88f95ee916326c78bb02445a5ff3870c6a63dee1f

Contents?: true

Size: 796 Bytes

Versions: 11

Compression:

Stored size: 796 Bytes

Contents

module Trestle
  module Generators
    class ResourceGenerator < ::Rails::Generators::NamedBase
      desc "Creates a Trestle admin resource"

      class_option :singular, type: :boolean, default: false, desc: "Generate a singular resource"

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

      def create_admin
        template "admin.rb.erb", File.join("app/admin", class_path, "#{admin_name}_admin.rb")
      end

      def admin_name
        singular? ? singular_name : plural_name
      end

      def parameter_name
        singular_name.singularize
      end

      def singular?
        options[:singular]
      end

    protected
      def module_name
        class_name.deconstantize
      end

      def module?
        module_name.present?
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/generators/trestle/resource/resource_generator.rb
trestle-0.10.0 lib/generators/trestle/resource/resource_generator.rb
trestle-0.10.0.pre2 lib/generators/trestle/resource/resource_generator.rb
trestle-0.10.0.pre lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.8 lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.7 lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.6 lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.5 lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.4 lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.3 lib/generators/trestle/resource/resource_generator.rb
trestle-0.9.2 lib/generators/trestle/resource/resource_generator.rb