Skip to content
Merged
Changes from all commits
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
7 changes: 2 additions & 5 deletions lib/annotate/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ 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)
args.detect { |arg| !arg.blank? }
args.detect(&:present?)
end

def reset_options(options)
Expand Down