class Atum::Generation::Generators::BaseGenerator
Constants
- TEMPLATE_NAME
Public Class Methods
new(module_name, schema, url, options)
click to toggle source
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.
@param module_name [String] The name of the module, as rendered in a Ruby
source file, to use for the generated client.
@param schema [Schema] The schema instance to generate the client from. @param url [String] The URL for the API service. @param options [Hash] Configuration for links. Possible keys include:
- default_headers: Optionally, a set of headers to include in every request made by the client. Default is no custom headers.
# 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
Public Instance Methods
context()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 24 def context ErbContext.new(context_hash.merge(module_name: @module_name)) end
context_hash()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 28 def context_hash raise NotImplementedError, 'Subclasses must define context_hash' end
generate()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 36 def generate template.evaluate(context) end
resources()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 40 def resources @schema.resource_schemas.map { |r| GeneratorResource.new(r) } end
template()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 32 def template @template ||= Erubis::Eruby.new(File.read(template_path)) end
Private Instance Methods
template_name()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 51 def template_name raise NotImplementedError, 'Subclasses must define template_name' end
template_path()
click to toggle source
# File lib/atum/generation/generators/base_generator.rb, line 46 def template_path File.expand_path(File.join(File.dirname(__FILE__), 'views', "#{template_name}.erb")) end