lib/shatter/service/service_definition.rb in shatter-rb-0.0.2 vs lib/shatter/service/service_definition.rb in shatter-rb-0.1.0

- old
+ new

@@ -1,21 +1,27 @@ +# frozen_string_literal: true + require "concurrent-ruby" -require 'set' module Shatter module Service class ServiceDefinition include Concurrent::Async class << self - attr_reader :function_collection + attr_accessor :function_collection end + + def self.to_typescript + function_defs = @function_collection.values + ERB.new(File.read("#{__dir__}/../../../templates/service_client.ts.erb")).result(binding) + end + def self.register_function(identifier, function) - Shatter.logger.info "Registering function - #{identifier} for #{self}" @function_collection ||= {} @function_collection[identifier.to_s] = function define_method identifier do |params| function.new(params).call end end end end -end \ No newline at end of file +end