Module: Castkit::DSL::DataObject::Serialization::ClassMethods

Defined in:
lib/castkit/dsl/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
43
44
45
# File 'lib/castkit/dsl/data_object/serialization.rb', line 40

def ignore_blank(value = nil)
  return (@ignore_blank = true) if value.nil? && !defined?(@ignore_blank)
  return @ignore_blank if value.nil?

  @ignore_blank = value
end

#ignore_nil(value = nil) ⇒ Boolean?

Sets or retrieves whether to skip nil values in output.



30
31
32
# File 'lib/castkit/dsl/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/dsl/data_object/serialization.rb', line 22

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