impress/app/models/closet_visibility.rb
Matchu 94d15f005d Delete a couple unused accessors
At least, I think they are!
2023-11-11 15:42:08 -08:00

54 lines
920 B
Ruby

module ClosetVisibility
class Level
attr_accessor :id, :name
def initialize(data)
data.each do |key, value|
send("#{key}=", value)
end
end
def description(subject=:items)
I18n.translate "closet_hangers.visibility.#{name}.description.#{subject}"
end
def human_name
I18n.translate "closet_hangers.visibility.#{name}.name"
end
def trading?
id >= LEVELS_BY_NAME[:trading].id
end
end
LEVELS = [
Level.new(
:id => 0,
:name => :private
),
Level.new(
:id => 1,
:name => :public
),
Level.new(
:id => 2,
:name => :trading
)
]
LEVELS_BY_NAME = {}.tap do |levels_by_name|
LEVELS.each do |level|
levels_by_name[level.id] = level
levels_by_name[level.name] = level
end
end
def self.[](id)
LEVELS_BY_NAME[id]
end
def self.levels
LEVELS
end
end