Skip to content

Commit 5f60b16

Browse files
authored
Merge pull request #174 from ngan/relative_date_example
Add another good example for RelativeDateConstant
2 parents 9e239be + 703f18e commit 5f60b16

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/rubocop/cop/rails/relative_date_constant.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ module Rails
1414
#
1515
# # good
1616
# class SomeClass
17+
# EXPIRES = 1.week
18+
#
19+
# def self.expired_at
20+
# EXPIRES.since
21+
# end
22+
# end
23+
#
24+
# # good
25+
# class SomeClass
1726
# def self.expired_at
1827
# 1.week.since
1928
# end

manual/cops_rails.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,15 @@ class SomeClass
19001900
EXPIRED_AT = 1.week.since
19011901
end
19021902

1903+
# good
1904+
class SomeClass
1905+
EXPIRES = 1.week
1906+
1907+
def self.expired_at
1908+
EXPIRES.since
1909+
end
1910+
end
1911+
19031912
# good
19041913
class SomeClass
19051914
def self.expired_at

0 commit comments

Comments
 (0)