style: if ! changed by unless
- if ! changed by unless as it is more readable - !object.blank? is equivalent to object.present?, also more readable
This commit is contained in:
parent
96155eb87f
commit
7e5d20c89d
18 changed files with 27 additions and 28 deletions
|
|
@ -551,7 +551,7 @@ class Conference < ActiveRecord::Base
|
|||
result[state.name] = count
|
||||
end
|
||||
|
||||
if !conference.events_per_week
|
||||
unless conference.events_per_week
|
||||
conference.events_per_week = {}
|
||||
end
|
||||
|
||||
|
|
@ -692,7 +692,7 @@ class Conference < ActiveRecord::Base
|
|||
events_per_week.each do |week, values|
|
||||
values.each do |state, value|
|
||||
if [:confirmed, :unconfirmed].include?(state)
|
||||
if !result[state.to_s.capitalize]
|
||||
unless result[state.to_s.capitalize]
|
||||
result[state.to_s.capitalize] = {}
|
||||
end
|
||||
result[state.to_s.capitalize][week.strftime('%W').to_i] = value
|
||||
|
|
@ -768,7 +768,7 @@ class Conference < ActiveRecord::Base
|
|||
def assert_keys_are_continuously(hash)
|
||||
keys = hash.keys
|
||||
(keys.min..keys.max).each do |key|
|
||||
if !hash[key]
|
||||
unless hash[key]
|
||||
hash[key] = 0
|
||||
end
|
||||
end
|
||||
|
|
@ -1004,7 +1004,7 @@ class Conference < ActiveRecord::Base
|
|||
# Adds a random color to the conference
|
||||
#
|
||||
def add_color
|
||||
if !color
|
||||
unless color
|
||||
self.color = get_color
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Contact < ActiveRecord::Base
|
|||
format: URI::regexp(%w(http https)), allow_blank: true
|
||||
|
||||
def has_social_media?
|
||||
return true if !facebook.blank? || !twitter.blank? || !googleplus.blank? || !instagram.blank? || !email.blank?
|
||||
return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || email.present?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -115,9 +115,7 @@ class Event < ActiveRecord::Base
|
|||
|
||||
def submitter
|
||||
result = event_users.where(event_role: 'submitter').first
|
||||
if !result.nil?
|
||||
result.user
|
||||
else
|
||||
if result.nil?
|
||||
user = nil
|
||||
# Perhaps the event_users haven't been saved, if this is a new proposal
|
||||
event_users.each do |u|
|
||||
|
|
@ -126,6 +124,8 @@ class Event < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
user
|
||||
else
|
||||
result.user
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ class Event < ActiveRecord::Base
|
|||
def generate_guid
|
||||
loop do
|
||||
@guid = SecureRandom.urlsafe_base64
|
||||
break if !self.class.where(guid: guid).any?
|
||||
break unless self.class.where(guid: guid).any?
|
||||
end
|
||||
self.guid = @guid
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class Venue < ActiveRecord::Base
|
|||
def generate_guid
|
||||
loop do
|
||||
@guid = SecureRandom.urlsafe_base64
|
||||
break if !Venue.where(guid: guid).any?
|
||||
break unless Venue.where(guid: guid).any?
|
||||
end
|
||||
self.guid = @guid
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue