Skip to content

Commit

Permalink
Merge pull request #174 from ngan/relative_date_example
Browse files Browse the repository at this point in the history
Add another good example for RelativeDateConstant
  • Loading branch information
koic authored Dec 17, 2019
2 parents 9e239be + 703f18e commit 5f60b16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/rubocop/cop/rails/relative_date_constant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ module Rails
#
# # good
# class SomeClass
# EXPIRES = 1.week
#
# def self.expired_at
# EXPIRES.since
# end
# end
#
# # good
# class SomeClass
# def self.expired_at
# 1.week.since
# end
Expand Down
9 changes: 9 additions & 0 deletions manual/cops_rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,15 @@ class SomeClass
EXPIRED_AT = 1.week.since
end

# good
class SomeClass
EXPIRES = 1.week

def self.expired_at
EXPIRES.since
end
end

# good
class SomeClass
def self.expired_at
Expand Down

0 comments on commit 5f60b16

Please sign in to comment.