Module: Castkit::Ext::DataObject::Serialization::ClassMethods

Defined in:
lib/castkit/ext/data_object/serialization.rb

Overview

Class-level configuration methods.

Instance Method Summary collapse

Instance Method Details

#ignore_blank(value = nil) ⇒ Boolean

Sets or retrieves whether to skip blank values (‘[]`, `{}`, `“”`, etc.) in output.

Defaults to true unless explicitly set to false.



40
41
42
# File 'lib/castkit/ext/data_object/serialization.rb', line 40

def ignore_blank(value = nil)
  @ignore_blank = value.nil? || value
end

#ignore_nil(value = nil) ⇒ Boolean?

Sets or retrieves whether to skip ‘nil` values in output.



30
31
32
# File 'lib/castkit/ext/data_object/serialization.rb', line 30

def ignore_nil(value = nil)
  value.nil? ? @ignore_nil : (@ignore_nil = value)
end

#root(value = nil) ⇒ Symbol?

Sets or retrieves the root key to wrap the object under during (de)serialization.



22
23
24
# File 'lib/castkit/ext/data_object/serialization.rb', line 22

def root(value = nil)
  value.nil? ? @root : (@root = value.to_s.strip.to_sym)
end