Sha256: d5e79da74adfa9beeb4b3b1183b9ad19d32a1c5887119952b413fcc460c4e002

Contents?: true

Size: 683 Bytes

Versions: 2

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

require "concurrent-ruby"

module Shatter
  module Service
    class ServiceDefinition
      include Concurrent::Async
      class << self
        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)
        @function_collection ||= {}
        @function_collection[identifier.to_s] = function
        define_method identifier do |params|
          function.new(params).call
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shatter-rb-0.1.1 lib/shatter/service/service_definition.rb
shatter-rb-0.1.0 lib/shatter/service/service_definition.rb