Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CamelCase elements always nil #64

Closed
milgner opened this issue Dec 3, 2015 · 2 comments
Closed

CamelCase elements always nil #64

milgner opened this issue Dec 3, 2015 · 2 comments

Comments

@milgner
Copy link

milgner commented Dec 3, 2015

If an element is CamelCased, its content always evaluates to nil:

pry(main)> foo = HappyMapper.parse("<foo><MessageId>f3a16e4c-b812-4934-a009-742ac51668b5</MessageId></foo>")
=> #<#<Class:0x00000002945e60>:0x000000029448d0 @message_id=nil>
pry(main)> foo.message_id
=> nil

Renaming the elements to lowercase yields correct content but since my input will always be camelcased, that's not an option.

@jweir
Copy link

jweir commented Dec 3, 2015

If you need a work around until this is fixed: explicitly set the tag name:

class Foo
  include HappyMapper

  tag 'foo'
  has_one :message_id, String, tag: 'MessageId'
end

Foo.parse "<foo><MessageId>f3a16e4c-b812-4934-a009-742ac51668b5</MessageId></foo>"
#=> <Foo:0x007fc774211798 @message_id="f3a16e4c-b812-4934-a009-742ac51668b5">

@milgner
Copy link
Author

milgner commented Dec 3, 2015

Thanks you for the hint. I had hoped to not need classes for every case, but I'll give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants