Sha256: 844cf1e69484c025b42888bb7cfe20396b5b72a09262f27a161a02024c04804c
Contents?: true
Size: 880 Bytes
Versions: 6
Compression:
Stored size: 880 Bytes
Contents
module EspSdk class Api attr_reader :end_points, :config def initialize(options = {}) fail MissingAttribute, 'Missing required email' if options[:email].blank? fail MissingAttribute, 'Missing required password or token' if options[:password].blank? && options[:token].blank? @config = Configure.new(options) @end_points = [] define_methods end private def define_methods end_points = EspSdk::EndPoints.constants - [:Base] end_points.each do |end_point| name = end_point.to_s.underscore define_singleton_method name do return instance_variable_get(:"@#{name}") if instance_variable_get(:"@#{name}").present? instance_variable_set(:"@#{name}", EspSdk::EndPoints.const_get(end_point).new(config)) end @end_points << send(name) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems