Class: Wrappix::Templates::Client
- Inherits:
-
Object
- Object
- Wrappix::Templates::Client
- Defined in:
- lib/wrappix/templates/client.rb
Class Method Summary collapse
Class Method Details
.render(module_name, config) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wrappix/templates/client.rb', line 6 def self.render(module_name, config) template = <<~RUBY # frozen_string_literal: true module #{module_name} class Client def initialize(configuration = #{module_name}.configuration) @configuration = configuration end #{resource_methods(module_name, config)} end end RUBY template.gsub(/^ +/, "") end |
.resource_methods(_module_name, config) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wrappix/templates/client.rb', line 23 def self.resource_methods(_module_name, config) resources = config["resources"] || {} resources.map do |name, _config| template = <<~RUBY.strip def #{name} @#{name} ||= Resources::#{name.capitalize}.new(self) end RUBY template.gsub(/^ +/, "") end.join("\n\n") end |