Sha256: 61d251ae302ea1f36407db0cc71172f7b019ea222e7e289488f931b9d9a8eaba
Contents?: true
Size: 593 Bytes
Versions: 5
Compression:
Stored size: 593 Bytes
Contents
module Moysklad::Entities class Base include Virtus.model attr_accessor :universe attr_accessor :dump def self.build(data, universe) entity = new data entity.universe = universe entity end def initialize(data = {}) data['attrs'] = data.delete 'attributes' if data['attributes'] super (data || {}).merge(dump: data) end def to_json(*args) presented = {} to_h.each_pair do |k, v| presented[k] = v unless v.nil? end presented.to_json end def to_s attributes.to_s end end end
Version data entries
5 entries across 5 versions & 1 rubygems