Class: Mongoid::Verbalize::TranslatedString::LocalizedValue
- Inherits:
-
Object
- Object
- Mongoid::Verbalize::TranslatedString::LocalizedValue
- Defined in:
- lib/mongoid/verbalize/translated_string.rb
Instance Attribute Summary collapse
-
#current_value ⇒ Object
Returns the value of attribute current_value.
-
#versions ⇒ Object
Returns the value of attribute versions.
Instance Method Summary collapse
- #add_version(new_version_number) ⇒ Object
- #changed? ⇒ Boolean
- #find_version(version) ⇒ Object
-
#initialize(current_value = nil, versions = []) ⇒ LocalizedValue
constructor
A new instance of LocalizedValue.
Constructor Details
#initialize(current_value = nil, versions = []) ⇒ LocalizedValue
Returns a new instance of LocalizedValue.
12 13 14 15 |
# File 'lib/mongoid/verbalize/translated_string.rb', line 12 def initialize(current_value=nil, versions=[]) @current_value = current_value @versions = versions end |
Instance Attribute Details
#current_value ⇒ Object
Returns the value of attribute current_value.
10 11 12 |
# File 'lib/mongoid/verbalize/translated_string.rb', line 10 def current_value @current_value end |
#versions ⇒ Object
Returns the value of attribute versions.
10 11 12 |
# File 'lib/mongoid/verbalize/translated_string.rb', line 10 def versions @versions end |
Instance Method Details
#add_version(new_version_number) ⇒ Object
22 23 24 |
# File 'lib/mongoid/verbalize/translated_string.rb', line 22 def add_version(new_version_number) versions.push(LocalizedVersion.new(new_version_number, current_value)) end |
#changed? ⇒ Boolean
17 18 19 20 |
# File 'lib/mongoid/verbalize/translated_string.rb', line 17 def changed? previous_version = versions.last previous_version.nil? || previous_version.value != current_value end |
#find_version(version) ⇒ Object
26 27 28 |
# File 'lib/mongoid/verbalize/translated_string.rb', line 26 def find_version(version) versions.find_all { |v| v.version <= version }.last end |