Class: WorkOS::DeprecatedHashWrapper

Inherits:
Hash
  • Object
show all
Defined in:
lib/workos/deprecated_hash_wrapper.rb

Overview

A Temporary wrapper class for a Hash, currently the base class for WorOS::DirectoryGroup and WorkOS::DirectoryUser. Makes all the Hash methods available to those classes, but will also emit a deprecation warning whenever any of them are used.

Once we deprecate Hash compatibility, this model can be deleted.

Direct Known Subclasses

DirectoryGroup, DirectoryUser

Instance Method Summary collapse

Instance Method Details

#[](attribute_name) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/workos/deprecated_hash_wrapper.rb', line 24

def [](attribute_name)
  usage = "#{object_name}.#{attribute_name}"
  warning_message = "WARNING: The Hash style access for #{class_name} attributes is deprecated
and will be removed in a future version. Please use `#{usage}` or equivalent accessor.\n"

  print_deprecation_warning('[]', warning_message)

  super(attribute_name.to_sym)
end

#replace_without_warning(new_hash) ⇒ Object

call the original implementation of :replace in Hash, so we don’t show the deprecation warning



20
21
22
# File 'lib/workos/deprecated_hash_wrapper.rb', line 20

def replace_without_warning(new_hash)
  method(:replace).super_method&.call(new_hash)
end