Sha256: b421e956f773294a452062c40d2f7e018f8ea40f6fd9e68d72ba76bcf0710a27

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

module Rails
  module Generators
   class DecoratorGenerator < NamedBase
      source_root File.expand_path("../templates", __FILE__)
      check_class_collision :suffix => "Decorator"

      class_option :parent, :type => :string, :desc => "The parent class for the generated decorator"

      def create_decorator_file
        template 'decorator.rb', File.join('app/decorators', class_path, "#{file_name}_decorator.rb")
      end

      hook_for :test_framework

      private

      def parent_class_name
        if options[:parent]
          options[:parent]
        elsif defined?(ApplicationDecorator)
          "ApplicationDecorator"
        else
          "Draper::Decorator"
        end
      end
   end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
draper-1.0.0.beta2 lib/generators/decorator/decorator_generator.rb
draper-1.0.0.beta1 lib/generators/decorator/decorator_generator.rb