Class: Enumerize::Value
- Inherits:
-
String
- Object
- String
- Enumerize::Value
- Includes:
- Predicatable
- Defined in:
- lib/enumerize/value.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #encode_with(coder) ⇒ Object
-
#initialize(attr, name, value = nil) ⇒ Value
constructor
A new instance of Value.
- #text ⇒ Object
Methods included from Predicatable
Constructor Details
#initialize(attr, name, value = nil) ⇒ Value
Returns a new instance of Value.
9 10 11 12 13 14 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Enumerize::Predicatable
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/enumerize/value.rb', line 7 def value @value end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 |
# File 'lib/enumerize/value.rb', line 20 def ==(other) super(other.to_s) || value == other end |
#encode_with(coder) ⇒ Object
24 25 26 |
# File 'lib/enumerize/value.rb', line 24 def encode_with(coder) coder.represent_object(self.class.superclass, @value) end |
#text ⇒ Object
16 17 18 |
# File 'lib/enumerize/value.rb', line 16 def text I18n.t(i18n_keys[0], :default => i18n_keys[1..-1]) end |