Skip to content

Commit

Permalink
Add support for Ruby 3
Browse files Browse the repository at this point in the history
code taken from this unmerged pull request: jackdempsey#76
  • Loading branch information
aschurg committed Jul 28, 2022
1 parent 9a728d9 commit 0aad49d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/commentable_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def define_role_based_inflection(role)

def define_role_based_inflection_3(role)
has_many "#{role.to_s}_comments".to_sym,
has_many_options(role).merge(:conditions => { role: role.to_s })
**has_many_options(role).merge(:conditions => { role: role.to_s })
end

def define_role_based_inflection_4(role)
has_many "#{role.to_s}_comments".to_sym,
-> { where(role: role.to_s) },
has_many_options(role)
**has_many_options(role)
end

def has_many_options(role)
Expand Down Expand Up @@ -53,9 +53,9 @@ def acts_as_commentable(*args)
comment_roles.each do |role|
define_role_based_inflection(role)
end
has_many :all_comments, { :as => :commentable, :dependent => :destroy, class_name: 'Comment' }.merge(join_options)
has_many :all_comments, **{ :as => :commentable, :dependent => :destroy, class_name: 'Comment' }.merge(join_options)
else
has_many :comments, {:as => :commentable, :dependent => :destroy}.merge(join_options)
has_many :comments, **{:as => :commentable, :dependent => :destroy}.merge(join_options)
end

comment_types.each do |role|
Expand Down

0 comments on commit 0aad49d

Please sign in to comment.