Sha256: 29836f0efa746a34d7e8a7fe78dd6df4938c313346af53938afae1812375a209

Contents?: true

Size: 769 Bytes

Versions: 4

Compression:

Stored size: 769 Bytes

Contents

require 'bundler/setup'
Bundler.require(:development)

require 'yaoc'

include Yaoc::Helper

puts "\n" * 5

OldUser5 = StructHE(:id, :name)

RoleThing = StructHE(:id, :role)

User5 = StructHE(:id, :name,  :role)


user_mapper = Yaoc::ObjectMapper.new(User5, OldUser5).tap do |mapper|
  mapper.add_mapping do
    fetcher :public_send
    rule to: [:id, :name]
  end
end

role_mapper = Yaoc::ObjectMapper.new(User5, RoleThing).tap do |mapper|
  mapper.add_mapping do
    fetcher :public_send
    rule to: [:role]
  end
end

old_role = RoleThing.new(id: 1, role: "my_role")
old_user5 = OldUser5.new(id: 1, name: "my fullname")
new_user5 = user_mapper.load(old_user5)

role_mapper.load(old_role, new_user5)

puts old_user5
puts old_role
puts new_user5



puts "\n" * 5




Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yaoc-0.0.9 examples/05_fill_existing_objects.rb
yaoc-0.0.8 examples/05_fill_existing_objects.rb
yaoc-0.0.7 examples/05_fill_existing_objects.rb
yaoc-0.0.6 examples/05_fill_existing_objects.rb