Sha256: 98acfc17bedeb8aa289d4be94cc10c5e8c82f76814b0662aeba11c8828d74627
Contents?: true
Size: 860 Bytes
Versions: 19
Compression:
Stored size: 860 Bytes
Contents
# typed: true # frozen_string_literal: true require 'json' module Workato module Connector module Sdk class WorkatoSchemas include Singleton class << self def from_json(path = DEFAULT_SCHEMAS_PATH) load_data(JSON.parse(File.read(path))) end delegate :find, :load_data, to: :instance end def load_data(data) @schemas_by_id ||= {}.with_indifferent_access @schemas_by_id.merge!(data.stringify_keys) end def find(id) unless @schemas_by_id raise 'Workato Schemas are not initialized. ' \ 'Init data by calling WorkatoSchemas.from_json or WorkatoSchemas.load_data' end @schemas_by_id.fetch(id.to_s) end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems