Class: Shatter::Service::ServiceDefinition

Inherits:
Object
  • Object
show all
Includes:
Concurrent::Async
Defined in:
lib/shatter/service/service_definition.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.function_collectionObject

Returns the value of attribute function_collection.



10
11
12
# File 'lib/shatter/service/service_definition.rb', line 10

def function_collection
  @function_collection
end

Class Method Details

.register_function(identifier, function) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/shatter/service/service_definition.rb', line 18

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

.to_typescriptObject



13
14
15
16
# File 'lib/shatter/service/service_definition.rb', line 13

def self.to_typescript
  function_defs = @function_collection.values
  ERB.new(File.read("#{__dir__}/../../../templates/service_client.ts.erb")).result(binding)
end