Skip to content

Commit 317bd08

Browse files
committed
Update class method syntax
1 parent 43bc855 commit 317bd08

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

app/models/settings/syntax_highlight.rb

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
class Settings::SyntaxHighlight
22
include ActiveModel::Model
33

4-
class << self
5-
def default
6-
find("dracula")
7-
end
4+
def self.default
5+
find("dracula")
6+
end
87

9-
def find(name)
10-
attrs = curated_data.find { |attrs| attrs[:name] == name }
11-
if attrs.present?
12-
new(**attrs)
13-
else
14-
raise ActiveRecord::RecordNotFound, "Couldn't find SyntaxHighlight with name '#{name}'"
15-
end
8+
def self.find(name)
9+
attrs = curated_data.find { |attrs| attrs[:name] == name }
10+
if attrs.present?
11+
new(**attrs)
12+
else
13+
raise ActiveRecord::RecordNotFound, "Couldn't find SyntaxHighlight with name '#{name}'"
1614
end
15+
end
1716

18-
def curated
19-
curated_data.map { |attrs| new(**attrs) }
20-
end
17+
def self.curated
18+
curated_data.map { |attrs| new(**attrs) }
19+
end
2120

22-
def curated_data
23-
@curated_data ||= YAML.load_file(Rails.root.join("config", "syntax_highlights.yml"))
24-
end
21+
def self.curated_data
22+
@curated_data ||= YAML.load_file(Rails.root.join("config", "syntax_highlights.yml"))
2523
end
2624

2725
attr_accessor :name, :mode

0 commit comments

Comments
 (0)