Module: OAuth2::FilteredAttributes
- Included in:
- AccessToken, Authenticator, Client
- Defined in:
- lib/oauth2/filtered_attributes.rb
Overview
Mixin that redacts sensitive instance variables in #inspect output.
Classes include this module and declare which attributes should be filtered
using filtered_attributes. Any instance variable name that includes one of
those attribute names will be shown as [FILTERED] in the object’s inspect.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ void
Hook invoked when the module is included.
Instance Method Summary collapse
-
#inspect ⇒ String
Custom inspect that redacts configured attributes.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Hook invoked when the module is included. Extends the including class with
class-level helpers.
13 14 15 |
# File 'lib/oauth2/filtered_attributes.rb', line 13 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#inspect ⇒ String
Custom inspect that redacts configured attributes.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/oauth2/filtered_attributes.rb', line 56 def inspect filtered_attribute_names = ClassMethods.filtered_attribute_names(self.class) return super if filtered_attribute_names.empty? inspected_vars = instance_variables.map do |var| if filtered_attribute_names.any? { |filtered_var| var.to_s.include?(filtered_var.to_s) } "#{var}=[FILTERED]" else "#{var}=#{instance_variable_get(var).inspect}" end end "#<#{self.class}:#{object_id} #{inspected_vars.join(", ")}>" end |