Skip to content

wrap doesn't work for custom getter #90

@fidalgo

Description

@fidalgo

For this example:

require 'happymapper'

class Root
  include HappyMapper

  tag 'Working'
  element :name, String
  wrap 'mywraptag' do
    element :description, String
    element :number, Integer
  end
  element :code, String

  def description
    'wooo'
  end

  def code
    'ABC123'
  end
end

root = Root.new
root.number = 12_345

puts root.to_xml

I have the following output:

<?xml version="1.0"?>
<Working>
  <mywraptag>
    <number>12345</number>
  </mywraptag>
  <code>ABC123</code>
</Working>

but if I comment the description method, and set the attribute like I do for the number it will generate the wrap tag as expected.

In my case I'm using those defined methods to get some fields from database objects, so I must admit that this could probably be not the most common scenario. Even though as far as I understand if should work.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions