You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
==== Methods That are Part of an Internal DSL [[method-invocation-parens-internal-dsl]][[method-call-parens-internal-dsl]]
3013
-
3014
-
Always omit parentheses for methods that are part of an internal DSL (e.g., Rake, Rails, RSpec):
3015
-
3016
-
[source,ruby]
3017
-
----
3018
-
# bad
3019
-
validates(:name, presence: true)
3020
-
# good
3021
-
validates :name, presence: true
3022
-
----
3023
-
3024
3016
==== Methods That Have "keyword" Status in Ruby [[method-invocation-parens-keyword]][[method-call-parens-keyword]]
3025
3017
3026
3018
Always omit parentheses for methods that have "keyword" status in Ruby.
@@ -3029,22 +3021,6 @@ NOTE: Unfortunately, it's not exactly clear _which_ methods have "keyword" statu
3029
3021
There is agreement that declarative methods have "keyword" status.
3030
3022
However, there's less agreement on which non-declarative methods, if any, have "keyword" status.
3031
3023
3032
-
===== Declarative Methods That Have "keyword" Status in Ruby [[method-invocation-parens-declarative-keyword]][[method-call-parens-declarative-keyword]]
3033
-
3034
-
Always omit parentheses for declarative methods (a.k.a. DSL methods or macro methods) that have "keyword" status in Ruby (e.g., various `Module` instance methods):
3035
-
3036
-
[source,ruby]
3037
-
----
3038
-
class Person
3039
-
# bad
3040
-
attr_reader(:name, :age)
3041
-
# good
3042
-
attr_reader :name, :age
3043
-
3044
-
# body omitted
3045
-
end
3046
-
----
3047
-
3048
3024
===== Non-Declarative Methods That Have "keyword" Status in Ruby [[method-invocation-parens-non-declarative-keyword]][[method-call-parens-non-declarative-keyword]]
3049
3025
3050
3026
For non-declarative methods with "keyword" status (e.g., various `Kernel` instance methods), two styles are considered acceptable.
0 commit comments