Class: Inttegro::CustomData

Inherits:
Hash
  • Object
show all
Extended by:
T::Generic, T::Sig
Defined in:
lib/inttegro/custom_data.rb

Overview

Immutable merchant-defined string values returned by the API.

Constant Summary collapse

K =
type_member(:out) { { fixed: String } }
V =
type_member(:out) { { fixed: String } }
Elem =
type_member(:out) { { fixed: T::Array[T.any(String, String)] } }

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ CustomData

Returns a new instance of CustomData.



21
22
23
24
25
26
27
28
29
# File 'lib/inttegro/custom_data.rb', line 21

def initialize(values = {})
  super()
  values.each do |key, value|
    CustomDataValidation.validate_key(key)
    self[key] = value
  end
  CustomDataValidation.validate_size(to_h)
  freeze
end

Instance Method Details

#remove(key) ⇒ Object



37
38
39
# File 'lib/inttegro/custom_data.rb', line 37

def remove(key)
  CustomData.new(to_h.reject { |candidate, _| candidate == key })
end

#set(key, value) ⇒ Object



32
33
34
# File 'lib/inttegro/custom_data.rb', line 32

def set(key, value)
  CustomData.new(to_h.merge(key => value))
end