Class: EnotasApi::Entity

Inherits:
Object
  • Object
show all
Includes:
Attributable
Defined in:
lib/enotas_api/common/entity.rb

Instance Method Summary collapse

Methods included from Attributable

#attribute_changed?, #attribute_type, #attributes, #attributes_changed, included, #initialize, #set

Instance Method Details

#as_json(_options = nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/enotas_api/common/entity.rb', line 12

def as_json(_options = nil)
  attributes.keys
            .map { |att| [att, json_value(att)] }
            .reject { |e| e[1].nil? && !attribute_changed?(e[0]) }
            .to_h
end

#to_json(options = nil) ⇒ Object



19
20
21
# File 'lib/enotas_api/common/entity.rb', line 19

def to_json(options = nil)
  as_json.to_json(options)
end