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

Custom :key_converter? #47

Open
sshaw opened this issue Sep 24, 2014 · 3 comments
Open

Custom :key_converter? #47

sshaw opened this issue Sep 24, 2014 · 3 comments

Comments

@sshaw
Copy link

sshaw commented Sep 24, 2014

Any reason not to accept something callable or allow one to add a converter?

The problem I've found is that some schemas upcase certain words. For example:

Ruby:camelcaseWanted
:product_id ProductIdProductID
:iso_codeIsoCodeISOCode
@tjarratt
Copy link
Contributor

tjarratt commented Dec 2, 2014

Hey @sshaw, I'm sorry that I did not respond sooner. I completely agree that this is a useful feature, and I'm very glad that @tvon issued a pull request for this functionality.

Do you feel his pull request resolves this? Perhaps we could release a new version of Gyoku with this and then close the issue?

@sshaw
Copy link
Author

sshaw commented Dec 3, 2014

Do you feel his pull request resolves this?

I haven't tried it out but it's better than nuthin'. Some thoughts:

  1. May be better to say respond_to?(:call) instead of is_a?(Proc). In some cases people might prefer to use a class.
  2. Given Gyoku's interface -i.e., Many calls to Gyoku.xml, it would be nice if one could add converters to FORMULA.

@sshaw
Copy link
Author

sshaw commented Dec 3, 2014

Given Gyoku's interface -i.e., Many calls to Gyoku.xml, it would be nice if one could add converters to FORMULA.

To clarify FORMULA is in XMLKey's singleton class and can't be accessed as if it were scoped to the module. Here's an example:

irb [2.1.2] (ember-test)$ class A 
1{                          class << self
2{                            X = 123
2{                            end
1{                          end
irb [2.1.2] (ember-test)$ A::X
NameError: uninitialized constant A::X
    from (irb):23
    from /Users/sshaw/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'
irb [2.1.2] (ember-test)$ A.singleton_class::X
=> 123

Was this intentional?

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