Module: KinopoiskDevApi::Types::Compactable

Included in:
Base
Defined in:
lib/kinopoisk_dev_api/types/compactable.rb

Instance Method Summary collapse

Instance Method Details

#to_compact_hashObject



6
7
8
9
10
11
12
# File 'lib/kinopoisk_dev_api/types/compactable.rb', line 6

def to_compact_hash
  attributes.dup.compact.to_h do |key, value|
    value = value.to_compact_hash if value.respond_to?(:to_compact_hash)

    [key, value]
  end
end

#to_json(*args) ⇒ Object



14
15
16
# File 'lib/kinopoisk_dev_api/types/compactable.rb', line 14

def to_json(*args)
  to_compact_hash.select { |_, v| v }.to_json(*args)
end