Class: Atum::Generation::Generators::BaseGenerator
- Inherits:
-
Object
- Object
- Atum::Generation::Generators::BaseGenerator
show all
- Defined in:
- lib/atum/generation/generators/base_generator.rb
Constant Summary
collapse
- TEMPLATE_NAME =
nil
Instance Method Summary
collapse
Constructor Details
#initialize(module_name, schema, url, options) ⇒ BaseGenerator
Generate a static client that uses Atum under the hood. This is a good option if you want to ship a gem or generate API documentation using Yard.
17
18
19
20
21
22
|
# File 'lib/atum/generation/generators/base_generator.rb', line 17
def initialize(module_name, schema, url, options)
@module_name = module_name
@schema = schema
@url = url
@options = options
end
|
Instance Method Details
#context ⇒ Object
24
25
26
|
# File 'lib/atum/generation/generators/base_generator.rb', line 24
def context
ErbContext.new(context_hash.merge(module_name: @module_name))
end
|
#context_hash ⇒ Object
28
29
30
|
# File 'lib/atum/generation/generators/base_generator.rb', line 28
def context_hash
raise NotImplementedError, 'Subclasses must define context_hash'
end
|
#generate ⇒ Object
36
37
38
|
# File 'lib/atum/generation/generators/base_generator.rb', line 36
def generate
template.evaluate(context)
end
|
#resources ⇒ Object
40
41
42
|
# File 'lib/atum/generation/generators/base_generator.rb', line 40
def resources
@schema.resource_schemas.map { |r| GeneratorResource.new(r) }
end
|
#template ⇒ Object
32
33
34
|
# File 'lib/atum/generation/generators/base_generator.rb', line 32
def template
@template ||= Erubis::Eruby.new(File.read(template_path))
end
|