-
Notifications
You must be signed in to change notification settings - Fork 476
corrects exposing of inline definitions #503
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
@@ -288,7 +288,8 @@ def expose_params_from_model(model) | |||
end | |||
|
|||
def model_name(name) | |||
name.respond_to?(:name) ? name.name.demodulize.camelize : name.split('::').last | |||
name = name.to_s.split('::')[0..-2].join('::').constantize if name.to_s.end_with?('Entity', 'Entities') |
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.
Why we can't just drop all '::', and show model name as is?
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.
good point … I did it, cause the name could be very long, see the spec, without it the name it would be: TestDefinitionClass1
, it would have all namespaces
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.
@Bugagazavr … what is your meaning?
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.
i think we can trim symbols if maximum defenition length is reached
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.
name.to_s.split('').reverse.take(255).reverse.join
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.
also we can add respond_to?(:entity_name)
to customize name manually
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.
where would it it be set?
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.
i think this should be placed in model_name
method
if name.respond_to?(:entity_name)
name.entity_name
else
name.to_s.gsub('::', '').split('').reverse.take(255).reverse.join
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.
yeap, but where in the entity/API definition would it be set?
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.
this should be a class method
length < 42 | ||
end.reverse.join | ||
else | ||
name.name.demodulize.camelize |
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.
I let it, cause without it, it would be a breaking change
- adds changelog entry - adds option to set definition name
- adds changelog entry - adds option to set definition name
I guess this is a late comment, but why there is 2 different code blocks for parsing model name?
Second question is what is the magic logic of dropping |
@serggl … thanks for spotting on it … it seems you have the knowledge to refactore it out, |
@LeFnord sure. On the way |
- adds changelog entry - adds option to set definition name
solves: