Class: Safire::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/safire/entity.rb

Direct Known Subclasses

ClientConfig, Protocols::SmartMetadata

Instance Method Summary collapse

Constructor Details

#initialize(params, attributes) ⇒ Entity

Returns a new instance of Entity.



3
4
5
# File 'lib/safire/entity.rb', line 3

def initialize(params, attributes)
  attributes.each { |name| instance_variable_set("@#{name}", params[name] || params[name.to_s]) }
end

Instance Method Details

#to_hashObject



7
8
9
10
11
12
13
14
15
# File 'lib/safire/entity.rb', line 7

def to_hash
  hash = {}
  instance_variables.each do |var|
    key = var.to_s.delete_prefix('@').to_sym
    value = instance_variable_get(var)
    hash[key] = sensitive_attributes.include?(key) && !value.nil? ? '[FILTERED]' : value
  end
  hash.deep_symbolize_keys
end