Sha256: d51a514883454d5d4e6cb7f0be3f6a2770c2bccee19bf0fb4e4aecd2823584cf

Contents?: true

Size: 864 Bytes

Versions: 5

Compression:

Stored size: 864 Bytes

Contents

require 'generators/common'
module Batman
  module Generators
    class ControllerGenerator < ::Rails::Generators::NamedBase
      include Common
      requires_app_name

      desc "This generator creates a Batman controller"
      argument :actions, :type => :array, :default => [], :banner => "action action"

      def create_batman_controller
        with_app_name do
          template "batman/controller.coffee", "#{app_path}/controllers/#{file_name.downcase}_controller.js.coffee"
          generate "batman:html #{plural_name} #{action_names} #{app_name_flag}"
          generate "batman:view  #{plural_name} #{action_names} #{app_name_flag}"
        end
      end

      def action_names
        return if actions.length == 0
        view_action_names = actions - %w[create update destroy]
        view_action_names.join(' ')
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
batman-rails-0.16.1 lib/generators/batman/controller_generator.rb
batman-rails-0.16.0 lib/generators/batman/controller_generator.rb
batman-rails-0.15.4 lib/generators/batman/controller_generator.rb
batman-rails-0.15.3 lib/generators/batman/controller_generator.rb
batman-rails-0.15.2 lib/generators/batman/controller_generator.rb