class Enumerize::Value

Attributes

value[R]

Public Class Methods

new(attr, name, value=nil) click to toggle source
Calls superclass method
# File lib/enumerize/value.rb, line 9
def initialize(attr, name, value=nil)
  @attr  = attr
  @value = value.nil? ? name.to_s : value

  super(name.to_s)
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/enumerize/value.rb, line 20
def ==(other)
  super(other.to_s) || value == other
end
encode_with(coder) click to toggle source
# File lib/enumerize/value.rb, line 24
def encode_with(coder)
  coder.represent_object(self.class.superclass, @value)
end
text() click to toggle source
# File lib/enumerize/value.rb, line 16
def text
  I18n.t(i18n_keys[0], :default => i18n_keys[1..-1])
end

Private Instance Methods

i18n_keys() click to toggle source
# File lib/enumerize/value.rb, line 34
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
i18n_scopes() click to toggle source
# File lib/enumerize/value.rb, line 44
def i18n_scopes
  @attr.i18n_scopes.map { |s| :"#{s}.#{self}" }
end
predicate_call(value) click to toggle source
# File lib/enumerize/value.rb, line 30
def predicate_call(value)
  value == self
end