Sha256: c17c07fdee5ef9083d00c1e7bcd90f0857ca5b7f307ab077e45c1f690766eff8

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

require 'rails/generators'

module Rails
  module Generators
    class ContextGenerator < NamedBase
      source_root File.expand_path('../template', __FILE__)

      check_class_collision :suffix => 'Context'

      class_option :parent,
        :type => :string,
        :desc => 'The parent class for the generated context'

      def create_context_file
        template(
          'context.rb',
          File.join(
            'app/contexts',
            class_path,
            "#{file_name}_context.rb"
          )
        )
      end

      private
      def parent_class_name
        options[:parent] || defined?(ApplicationContext) ?
          'ApplicationContext' : 'Dicer::Context'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dicer-0.0.1 lib/generators/context/context_generator.rb