module CinnamonSerial::Dsl

This module includes all the class-level methods used to specify serializers.

Public Instance Methods

cinnamon_serial_specification() click to toggle source
# File lib/cinnamon_serial/dsl.rb, line 13
def cinnamon_serial_specification
  @cinnamon_serial_specification ||= Specification.new
end
hydrate(&block) click to toggle source
# File lib/cinnamon_serial/dsl.rb, line 23
def hydrate(&block)
  cinnamon_serial_specification.hydrate(block)

  nil
end
inherited_cinnamon_serial_specification() click to toggle source
# File lib/cinnamon_serial/dsl.rb, line 29
def inherited_cinnamon_serial_specification
  return @inherited_cinnamon_serial_specification if @inherited_cinnamon_serial_specification

  attribute_map  = {}
  hydrate_blocks = []

  # We need to reverse this so parents go first.
  ancestors.reverse_each do |ancestor|
    next unless ancestor.respond_to?(:cinnamon_serial_specification)

    specification = ancestor.cinnamon_serial_specification

    attribute_map.merge!(specification.attribute_map)
    hydrate_blocks += specification.hydrate_blocks
  end

  @inherited_cinnamon_serial_specification = Specification.new(
    attribute_map: attribute_map,
    hydrate_blocks: hydrate_blocks
  )
end
serialize(*keys) click to toggle source
# File lib/cinnamon_serial/dsl.rb, line 17
def serialize(*keys)
  cinnamon_serial_specification.set(keys)

  nil
end