Sha256: 617af66b6a3ad0d933548c2f23b454c6d7aee297d0a213b5878da4ecb2b0f9d0

Contents?: true

Size: 516 Bytes

Versions: 10

Compression:

Stored size: 516 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 = {})
      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

10 entries across 10 versions & 1 rubygems

Version Path
moysklad-0.5 lib/moysklad/entities/base.rb
moysklad-0.4.10 lib/moysklad/entities/base.rb
moysklad-0.4.9 lib/moysklad/entities/base.rb
moysklad-0.4.8 lib/moysklad/entities/base.rb
moysklad-0.4.7 lib/moysklad/entities/base.rb
moysklad-0.4.6 lib/moysklad/entities/base.rb
moysklad-0.4.5 lib/moysklad/entities/base.rb
moysklad-0.4.4 lib/moysklad/entities/base.rb
moysklad-0.4.3 lib/moysklad/entities/base.rb
moysklad-0.4.2 lib/moysklad/entities/base.rb