Module: LaserLemon::DrySerial::ClassMethods

Defined in:
lib/dry_serial.rb

Instance Method Summary collapse

Instance Method Details

#default_serialization_optionsObject



29
30
31
# File 'lib/dry_serial.rb', line 29

def default_serialization_options
  self.serialization_options.fetch(self.default_serialization_style, {})
end

#dry_serial(*args) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/dry_serial.rb', line 21

def dry_serial(*args)
  options = args.extract_options!
  style = args.first || :default

  self.serialization_options[style] = options
  self.default_serialization_style ||= style
end

#styled_serialization_options(*args) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/dry_serial.rb', line 33

def styled_serialization_options(*args)
  options = args.extract_options!
  style = args.first || options[:style] || default_serialization_style

  style_options = serialization_options.fetch(style, default_serialization_options)
  style_options.merge(options).merge(:style => style)
end