Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 483 Bytes

serialize_to_poro.md

File metadata and controls

32 lines (21 loc) · 483 Bytes

Serialize to PORO

can be used for the refactoring: replace primitive with object

serialize

Example

class User
  # role is a string field
  serialize :role, Role
end


class Role
  
  attr_readr :name

  def initialize(role_name)
    @name = role_name
  end  

  def self.load(value)
     Role.new value
  end

  def self.dump(value)
    Role.new(value).name
  end