123456789_123456789_123456789_123456789_123456789_

Class: Rails::Generators::ChannelGenerator

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, NamedBase, Base, Thor::Group
Instance Chain:
self, NamedBase, Base, Actions, Thor::Actions, Thor::Group
Inherits: Rails::Generators::NamedBase
Defined in: actioncable/lib/rails/generators/channel/channel_generator.rb

Class Method Summary

NamedBase - Inherited

.check_class_collision

Add a class collisions name to be checked on class initialization.

Base - Inherited

.base_root

Returns the base root for a common set of generators.

.default_source_root

Returns the default source root for a given generator.

.desc

Tries to get the description from a USAGE file one folder above the source root otherwise uses a default description.

.hide!

Convenience method to hide this generator from the available ones when running rails generator command.

.hook_for

Invoke a generator based on the value supplied by the user to the given option named “name”.

.namespace

Convenience method to get the namespace from the class name.

.remove_hook_for

Remove a previously added hook.

.source_root

Returns the source root for this generator using default_source_root as default.

.add_shebang_option!

Small macro to add ruby as an option to the generator with proper default value plus an instance helper method called shebang.

.banner

Use Rails default banner.

.base_name

Sets the base_name taking into account the current class namespace.

.default_aliases_for_option

Returns default aliases for the option name given doing a lookup in aliases.

.default_for_option

Returns default for the option name given doing a lookup in config.

.default_generator_root,
.default_value_for_option

Returns the default value for the option name given doing a lookup in options.

.generator_name

Removes the namespaces and get the generator name.

.usage_path

Instance Attribute Summary

Instance Method Summary

NamedBase - Inherited

Base - Inherited

#extract_last_module

Takes in an array of nested modules and extracts the last module.

#indent,
#module_namespacing

Wrap block with namespace of current application if namespace exists and is not skipped.

#namespace, #namespaced_path, #wrap_with_namespace

Actions - Included

#add_source

Add the given source to Gemfile

#after_bundle

Registers a callback to be executed after bundle and spring binstubs have run.

#application
#capify!

Just run the capify command in root.

#environment

Adds a line inside the ::Rails::Application class for config/application.rb.

#gem

Adds an entry into Gemfile for the supplied gem.

#gem_group

Wraps gem entries inside a group.

#generate

Generate something using a generator from ::Rails or a plugin.

#git

Run a command in git.

#initializer

Create a new initializer with the provided code (either in a block or a string).

#lib

Create a new file in the lib/ directory.

#rails_command

Runs the supplied rake task (invoked with ‘rails …’).

#rake

Runs the supplied rake task (invoked with ‘rake …’).

#rakefile

Create a new Rakefile with the provided code (either in a block or a string).

#readme

Reads the given file at the source root and prints it in the console.

#route

Make an entry in ::Rails routing file config/routes.rb.

#vendor

Create a new file in the vendor/ directory.

#execute_command

Runs the supplied command using either “rake …” or “rails …” based on the executor parameter provided.

#extify

Add an extension to the given name based on the platform.

#log

Define log for backwards compatibility.

#optimize_indentation

Returns optimized string with indentation.

#quote

Surround string with single quotes if there is no quotes.

Instance Method Details

#create_channel_file

[ GitHub ]

  
# File 'actioncable/lib/rails/generators/channel/channel_generator.rb', line 14

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

  if options[:assets]
    if behavior == :invoke
      template "assets/cable.js", "app/assets/javascripts/cable.js"
    end

    js_template "assets/channel", File.join("app/assets/javascripts/channels", class_path, "#{file_name}")
  end

  generate_application_cable_files
end