Skip to content

Commit

Permalink
Merge pull request #45 from ifad/chore/use-empty-instead-of-comparing…
Browse files Browse the repository at this point in the history
…-size

Use empty and present instead of checking size
  • Loading branch information
tagliala authored Jan 22, 2024
2 parents 6775b27 + 516bdd1 commit 14ff4b9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
10 changes: 0 additions & 10 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/hawk/http/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def instrument(type, payload)
elapsed = (Time.now.to_f - start) * 1000

url = payload[:url].to_s
if payload[:params] && payload[:params].size > 0
if payload[:params].present?
url << '?' << payload[:params].inject('') { |s, (k, v)| s << [k, '=', v, '&'].join }.chomp('&')
end

Expand Down
4 changes: 2 additions & 2 deletions lib/hawk/model/association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.included(base)
#
def initialize(attributes = {}, params = {})
super
if attributes.size > 0 && self.class.associations?
if attributes.present? && self.class.associations?
preload_associations(attributes, params, self.class)
end
end
Expand Down Expand Up @@ -136,7 +136,7 @@ def associations
# Check whether associations are defined
#
def associations?
@_associations && @_associations.size > 0
@_associations.present?
end

# Check whether the given attribute is an association
Expand Down
2 changes: 1 addition & 1 deletion lib/hawk/model/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def cast!(attributes)
end

def schema(attributes = nil)
if attributes && attributes.size > 0 && self.class.schema.nil?
if attributes.present? && self.class.schema.nil?
self.class.define_schema_from(attributes)
end
self.class.schema || {}
Expand Down

0 comments on commit 14ff4b9

Please sign in to comment.