Skip to content

Conversation

nard-tech
Copy link
Collaborator

I refactored two methods in AnnotateModels::Helpers for readability.

return false unless val =~ Constants::TRUE_RE

true
val.present? && Constants::TRUE_RE.match?(val)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def true?(val) return false if val.blank? return false unless val =~ Constants::TRUE_RE true

can be refactored to

def true?(val) if val.blank? false else if val =~ Constants::TRUE_RE true else false end end end

So we can easily replace them to a one liner method.

I used Regexp#match? instead of String#=~ because String#=~ returns nil or an integer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice

Copy link
Collaborator

@drwl drwl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good keep it up :)

return false unless val =~ Constants::TRUE_RE

true
val.present? && Constants::TRUE_RE.match?(val)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice

@drwl drwl merged commit 1c5deb0 into ctran:develop Jan 18, 2020
@nard-tech nard-tech deleted the feature/refactor_annotate_models/helpers branch January 19, 2020 09:15
vfonic pushed a commit to vfonic/annotate_models that referenced this pull request May 8, 2020
I refactored two methods in AnnotateModels::Helpers for readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants