Sha256: 7c038e3cb42a7bb2d18a5146a9ed6c359383478e58d24730fd0c10735ece55e1
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# typed: false # frozen_string_literal: true require 'csv' require 'erb' require 'singleton' module Workato module Connector module Sdk class AccountProperties include Singleton def self.from_yaml(path = DEFAULT_ACCOUNT_PROPERTIES_PATH) File.open(path) do |f| instance.load_data(YAML.safe_load(ERB.new(f.read).result, [::Symbol]).to_hash) end end def self.from_encrypted_yaml(path = DEFAULT_ENCRYPTED_ACCOUNT_PROPERTIES_PATH, key_path = nil) load_data( ActiveSupport::EncryptedConfiguration.new( config_path: path, key_path: key_path || DEFAULT_MASTER_KEY_PATH, env_key: DEFAULT_MASTER_KEY_ENV, raise_if_missing_key: true ).config ) end def self.from_csv(path = './account_properties.csv') props = CSV.foreach(path, headers: true, return_headers: false).to_h do |row| [row[0], row[1]] end instance.load_data(props) end class << self delegate :load_data, :get, :put, to: :instance end def get(key) @data ||= {} @data[key.to_s] end def put(key, value) @data ||= {} @data[key.to_s] = value.to_s end def load_data(props = {}) props.each { |k, v| put(k, v) } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
workato-connector-sdk-1.3.0 | lib/workato/connector/sdk/account_properties.rb |