Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor Annotate::Helpers.true?
  • Loading branch information
nard-tech committed Jan 17, 2020
commit 805b603cac5c5d273dae90009157a2b0fc7fc5b8
5 changes: 1 addition & 4 deletions lib/annotate/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ def include_models?
end

def true?(val)
return false if val.blank?
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

end

def fallback(*args)
Expand Down