Sha256: dddb65f50092781f7de6b0047a06a08ec614433853643c8d44d82a39cea1db20

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

module Generators
  module Hobo
    Controller = classy_module do

      check_class_collision :suffix => 'Controller'

      class_option :helpers, :type => :boolean,
      :desc => "Generates helper files",
      :default => !Rails.application.config.hobo.dryml_only_templates

      def self.banner
      "rails generate hobo:controller #{self.arguments.map(&:usage).join(' ')}"
      end

      def generate_controller
        if class_path.length == 1 and
          subsite = class_path.first and
          File.exist?(File.join('app/controllers', class_path, "#{subsite}_site_controller.rb"))
          @subsite = subsite.camelize
        end
        template 'controller.rb.erb', File.join('app/controllers',"#{file_path}_controller.rb")
      end

      def generate_helper
        return unless options[:helpers]
        invoke 'helper', [name], options
      end

      hook_for :test_framework, :as => :controller do | instance, controller_test |
        instance.invoke controller_test, [ instance.name ]
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hobo-1.3.0.pre27 lib/generators/hobo/controller.rb
hobo-1.3.0.pre26 lib/generators/hobo/controller.rb
hobo-1.3.0.pre25 lib/generators/hobo/controller.rb
hobo-1.3.0.pre24 lib/generators/hobo/controller.rb