Class: Inttegro::CustomDataInput
- Inherits:
-
Hash
- Object
- Hash
- Inttegro::CustomDataInput
- Extended by:
- T::Generic, T::Sig
- Defined in:
- lib/inttegro/custom_data.rb
Overview
Immutable open-ended JSON values accepted by create and replace requests.
Constant Summary collapse
- K =
type_member(:out) { { fixed: String } }
- V =
type_member(:out) { { fixed: Object } }
- Elem =
type_member(:out) { { fixed: T::Array[T.any(String, Object)] } }
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ CustomDataInput
constructor
A new instance of CustomDataInput.
- #remove(key) ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ CustomDataInput
Returns a new instance of CustomDataInput.
52 53 54 55 56 57 58 59 60 |
# File 'lib/inttegro/custom_data.rb', line 52 def initialize(values = {}) super() values.each do |key, value| CustomDataValidation.validate_key(key) self[key] = CustomDataValidation.copy_json(value) end CustomDataValidation.validate_size(to_h) freeze end |
Instance Method Details
#remove(key) ⇒ Object
68 69 70 |
# File 'lib/inttegro/custom_data.rb', line 68 def remove(key) CustomDataInput.new(to_h.reject { |candidate, _| candidate == key }) end |
#set(key, value) ⇒ Object
63 64 65 |
# File 'lib/inttegro/custom_data.rb', line 63 def set(key, value) CustomDataInput.new(to_h.merge(key => value)) end |