/usr/lib/ruby/vendor_ruby/enumerize/value.rb is in ruby-enumerize 1.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | require 'i18n'
module Enumerize
class Value < String
include Predicatable
attr_reader :value
def initialize(attr, name, value=nil)
@attr = attr
@value = value.nil? ? name.to_s : value
super(name.to_s)
end
def text
I18n.t(i18n_keys[0], :default => i18n_keys[1..-1])
end
def ==(other)
super(other.to_s) || value == other
end
def encode_with(coder)
coder.represent_object(self.class.superclass, @value)
end
private
def predicate_call(value)
value == self
end
def i18n_keys
@i18n_keys ||= begin
i18n_keys = i18n_scopes
i18n_keys << [:"enumerize.defaults.#{@attr.name}.#{self}"]
i18n_keys << [:"enumerize.#{@attr.name}.#{self}"]
i18n_keys << self.underscore.humanize # humanize value if there are no translations
i18n_keys.flatten
end
end
def i18n_scopes
@attr.i18n_scopes.map { |s| :"#{s}.#{self}" }
end
end
end
|