Skip to content

Commit

Permalink
protected visibility is discouraged (#1687)
Browse files Browse the repository at this point in the history
Coming from other languages, it's tempting to use `protected` in Ruby.
However this keyword has different nuanced in Ruby and is generally
discouraged. It should only be used for methods required for comparators
and operators. None of the methods marked as `protected` here fall into
this category, so I think they should be marked `private` instead.
  • Loading branch information
pablobm committed Jun 25, 2020
1 parent 1864710 commit 844c270
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/administrate/field/associative.rb
Expand Up @@ -11,7 +11,7 @@ def associated_class
associated_class_name.constantize
end

protected
private

def associated_dashboard
"#{associated_class_name}Dashboard".constantize.new
Expand Down
2 changes: 1 addition & 1 deletion lib/administrate/field/polymorphic.rb
Expand Up @@ -23,7 +23,7 @@ def selected_global_id
data ? data.to_global_id : nil
end

protected
private

def associated_dashboard(klass = data.class)
"#{klass.name}Dashboard".constantize.new
Expand Down
2 changes: 1 addition & 1 deletion lib/administrate/page/base.rb
Expand Up @@ -23,7 +23,7 @@ def item_includes
dashboard.try(:item_includes) || []
end

protected
private

def attribute_field(dashboard, resource, attribute_name, page)
value = get_attribute_value(resource, attribute_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/administrate/page/form.rb
Expand Up @@ -20,7 +20,7 @@ def page_title
dashboard.display_resource(resource)
end

protected
private

attr_reader :dashboard
end
Expand Down

0 comments on commit 844c270

Please sign in to comment.