Sha256: 344fc22738f3d458ad1155059a9d098ab461a79dacf30d1be2bdcc0c1747e1fe

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Generators
    # Create an class for generate a installing
    class InstallGenerator < Rails::Generators::Base
      desc 'Install RubyRabbitmqJanus in your Rails application'
      ACTION_CLASS = <<-BASE
module RubyRabbitmqJanus
  # Execute this code when janus return an events in standard queue
  class ActionsEvents
    # Default method using for sending a block of code
    def actions
      lambda do |reason, data|
        Rails.logger.debug "Execute block code with reason : \#{reason}"
        case reason
        when event this case_events(data.to_hash)
        end
      end
    end

    private

    def case_events(data)
      Rails.logger.debug "Event : \#{data}"
    end
  end
end
      BASE
      APPLICATION = <<-AUTOLOAD
# Load RubyRabbitmqJanus actions events code blocks
config.autoload_paths += Dir[Rails.root.join('app', 'ruby_rabbitmq_janus')]
      AUTOLOAD

      def add_actions
        # Create an class
        create_file 'app/ruby_rabbitmq_janus/actions.rb', ACTION_CLASS

        # Add to application.rb
        application do
          APPLICATION
        end

        # Add initializer
        generate 'ruby_rabbitmq_janus:initializer'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-1.1.12 lib/generators/ruby_rabbitmq_janus/install_generator.rb
ruby_rabbitmq_janus-1.1.11 lib/generators/ruby_rabbitmq_janus/install_generator.rb
ruby_rabbitmq_janus-1.1.10 lib/generators/ruby_rabbitmq_janus/install_generator.rb
ruby_rabbitmq_janus-1.1.9 lib/generators/ruby_rabbitmq_janus/install_generator.rb