Class: ActiveAgent::Generators::AgentGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ActiveAgent::Generators::AgentGenerator
- Defined in:
- lib/generators/active_agent/agent/agent_generator.rb
Instance Method Summary collapse
- #create_agent_file ⇒ Object
-
#initialize(*args, **kwargs) ⇒ AgentGenerator
constructor
A new instance of AgentGenerator.
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 = .merge(template_engine: :erb) end |
Instance Method Details
#create_agent_file ⇒ Object
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 |