Class: Globalize::ActiveRecord::Attributes

Inherits:
Hash
  • Object
show all
Defined in:
lib/globalize/active_record/attributes.rb

Overview

TODO: Think about using HashWithIndifferentAccess ?

Instance Method Summary collapse

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

Returns:

  • (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