Class: ActiveAgent::Generators::AgentGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/active_agent/agent/agent_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, **kwargs) ⇒ AgentGenerator

Returns a new instance of AgentGenerator.



14
15
16
17
18
19
20
# File 'lib/generators/active_agent/agent/agent_generator.rb', line 14

def initialize(*args, **kwargs)
  super(*args, **kwargs)

  # We must duplicate due to immutable hash
  dup_options = options.dup
  @options = dup_options.merge(template_engine: :erb)
end

Instance Method Details

#create_agent_fileObject



22
23
24
25
26
27
28
29
30
# File 'lib/generators/active_agent/agent/agent_generator.rb', line 22

def create_agent_file
  template "agent.rb", File.join("app/agents", class_path, "#{file_name}_agent.rb")

  in_root do
    if behavior == :invoke && !File.exist?(application_agent_file_name)
      template "application_agent.rb", application_agent_file_name
    end
  end
end