module Polyseerio::SDK::Helper
SDK
helpers.
Public Class Methods
accumulate_procs(*args)
click to toggle source
Accumulates a function type from a map into an accumulator.
# File lib/sdk/helper.rb, line 29 def self.accumulate_procs(*args) proc do |type, map, name, acc| unless map.key? name raise "SDK factory could not find a #{type} #{name}." end acc[name] = map.fetch(name) acc end.curry.call(*args) end
instance_to_uri(instance)
click to toggle source
Takes an instance and returns a uri.
# File lib/sdk/helper.rb, line 20 def self.instance_to_uri(instance) URL.get_resource_path( instance.type, eid: instance.eid, id: instance.id ) end
reduce_options(options, copts = {}, defaults = {})
click to toggle source
Reduce method options with client options and method defaults
# File lib/sdk/helper.rb, line 42 def self.reduce_options(options, copts = {}, defaults = {}) defaults.merge(copts).merge(options) end
remove_non_resolving_values(hash)
click to toggle source
Takes a hash and returns a new one that only contains values that are blocks / procs / anything callable aka resolvable.
# File lib/sdk/helper.rb, line 11 def self.remove_non_resolving_values(hash) hash.each_with_object({}) do |(key, value), acc| acc[key] = value if value.respond_to? :call acc end end
resolve_eid(options)
click to toggle source
Determine the eid given a reduced options hash
# File lib/sdk/helper.rb, line 47 def self.resolve_eid(options) return options[:environment] if options.key? :environment if options[:deduce] env = options.fetch(:env) return ENV.fetch env if ENV.key? env end Constant::DEFAULT_ENVIRONMENT end