Class: Globalize::ActiveRecord::Attributes
- Inherits:
-
Hash
- Object
- Hash
- Globalize::ActiveRecord::Attributes
- Defined in:
- lib/globalize/active_record/attributes.rb
Overview
TODO: Think about using HashWithIndifferentAccess ?
Instance Method Summary collapse
- #[](locale) ⇒ Object
- #contains?(locale, name) ⇒ Boolean
- #read(locale, name) ⇒ Object
- #write(locale, name, value) ⇒ Object
Instance Method Details
#[](locale) ⇒ Object
7 8 9 10 11 |
# File 'lib/globalize/active_record/attributes.rb', line 7 def [](locale) locale = locale.to_sym self[locale] = {} unless has_key?(locale) self.fetch(locale) end |
#contains?(locale, name) ⇒ Boolean
13 14 15 |
# File 'lib/globalize/active_record/attributes.rb', line 13 def contains?(locale, name) self[locale].has_key?(name.to_s) end |
#read(locale, name) ⇒ Object
17 18 19 |
# File 'lib/globalize/active_record/attributes.rb', line 17 def read(locale, name) self[locale][name.to_s] end |
#write(locale, name, value) ⇒ Object
21 22 23 |
# File 'lib/globalize/active_record/attributes.rb', line 21 def write(locale, name, value) self[locale][name.to_s] = value end |