-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Namespace separator setting for json-api and tests #1791
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,5 +66,26 @@ def underscore(value) | |
def unaltered(value) | ||
value | ||
end | ||
|
||
# Transforms string to selected case | ||
# Accepts string in any case: 'camel', 'undescore', 'dashed'. | ||
# | ||
# @example: | ||
# transform('SomeClass', :underscore) => 'some_class' | ||
# transform('some_class', :snake) => 'someClass' | ||
# etc... | ||
def transform(string, type) | ||
string = string.underscore | ||
case type.to_sym | ||
when :dashed | ||
string.dasherize | ||
when :camel | ||
string.camelize | ||
when :snake | ||
string.camelize(:lower) | ||
else | ||
string | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It pre-existed.. And fixing merge conflicts didn't fix feature dup. Am hoping someone to finish:) B mobile phone
|
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type transform is underscore? doesn't this go against our other transform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup... This is why it needs a thoughtful review :)
B mobile phone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we had the default what it is now?