Sha256: ec9f0d9968930e9f293b1dc5c657c3aaa023ba8e79426a865a1e54040c91a676

Contents?: true

Size: 727 Bytes

Versions: 1

Compression:

Stored size: 727 Bytes

Contents

module Rails
  module Generators
    class ChannelGenerator < NamedBase
      source_root File.expand_path("../templates", __FILE__)

      argument :actions, type: :array, default: [], banner: "method method"

      class_option :assets, type: :boolean

      check_class_collision suffix: "Channel"

      def create_channel_file
        template "channel.rb", File.join('app/channels', class_path, "#{file_name}_channel.rb")

        if options[:assets]
          template "assets/channel.coffee", File.join('app/assets/javascripts/channels', class_path, "#{file_name}.coffee")
        end
      end

      protected
        def file_name
          @_file_name ||= super.gsub(/\_channel/i, '')
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actioncable-5.0.0.beta2 lib/rails/generators/channel/channel_generator.rb