moves polymorphic_class_for in registered_bookmarkable_from_type

This commit is contained in:
Joffrey JAFFEUX 2023-03-17 16:50:06 +01:00
parent efefbe9e3d
commit 39aebeac60

View File

@ -10,7 +10,8 @@ class Bookmark < ActiveRecord::Base
Set.new(DEFAULT_BOOKMARKABLES | DiscoursePluginRegistry.bookmarkables)
end
def self.registered_bookmarkable_from_type(type)
def self.registered_bookmarkable_from_type(bookmarkable_type)
type = Bookmark.polymorphic_class_for(bookmarkable_type).name
Bookmark.registered_bookmarkables.find { |bm| bm.model.name == type }
end
@ -46,8 +47,7 @@ class Bookmark < ActiveRecord::Base
validates :name, length: { maximum: 100 }
def registered_bookmarkable
type = Bookmark.polymorphic_class_for(self.bookmarkable_type).name
Bookmark.registered_bookmarkable_from_type(type)
Bookmark.registered_bookmarkable_from_type(self.bookmarkable_type)
end
def polymorphic_columns_present