Class: Safire::Entity
- Inherits:
-
Object
- Object
- Safire::Entity
- Defined in:
- lib/safire/entity.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(params, attributes) ⇒ Entity
constructor
A new instance of Entity.
- #to_hash ⇒ Object
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_hash ⇒ Object
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 |