Class: Moysklad::Entities::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/moysklad/entities/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
# File 'lib/moysklad/entities/base.rb', line 13

def initialize(data = {})
  super data.merge(dump: data)
end

Instance Attribute Details

#dumpObject

Returns the value of attribute dump.



5
6
7
# File 'lib/moysklad/entities/base.rb', line 5

def dump
  @dump
end

#universeObject

Returns the value of attribute universe.



4
5
6
# File 'lib/moysklad/entities/base.rb', line 4

def universe
  @universe
end

Class Method Details

.build(data, universe) ⇒ Object



7
8
9
10
11
# File 'lib/moysklad/entities/base.rb', line 7

def self.build(data, universe)
  entity = new data
  entity.universe = universe
  entity
end

Instance Method Details

#to_json(*args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/moysklad/entities/base.rb', line 17

def to_json(*args)
  presented = {}
  to_h.each_pair do |k, v|
    presented[k] = v unless v.nil?
  end

  presented.to_json
end

#to_sObject



26
27
28
# File 'lib/moysklad/entities/base.rb', line 26

def to_s
  attributes.to_s
end