Class: I18n::Backend::KeyValue::SubtreeProxy
- Inherits:
-
Object
- Object
- I18n::Backend::KeyValue::SubtreeProxy
- Defined in:
- lib/i18n/backend/key_value.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(master_key, store) ⇒ SubtreeProxy
constructor
A new instance of SubtreeProxy.
- #inspect ⇒ Object
- #instance_of?(klass) ⇒ Boolean
- #is_a?(klass) ⇒ Boolean (also: #kind_of?)
- #nil? ⇒ Boolean
Constructor Details
#initialize(master_key, store) ⇒ SubtreeProxy
Returns a new instance of SubtreeProxy.
164 165 166 167 168 |
# File 'lib/i18n/backend/key_value.rb', line 164 def initialize(master_key, store) @master_key = master_key @store = store @subtree = nil end |
Instance Method Details
#[](key) ⇒ Object
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/i18n/backend/key_value.rb', line 174 def [](key) unless @subtree && value = @subtree[key] value = @store["#{@master_key}.#{key}"] if value value = JSON.decode(value) (@subtree ||= {})[key] = value end end value end |
#has_key?(key) ⇒ Boolean
170 171 172 |
# File 'lib/i18n/backend/key_value.rb', line 170 def has_key?(key) @subtree && @subtree.has_key?(key) || self[key] end |
#inspect ⇒ Object
198 199 200 |
# File 'lib/i18n/backend/key_value.rb', line 198 def inspect @subtree.inspect end |
#instance_of?(klass) ⇒ Boolean
190 191 192 |
# File 'lib/i18n/backend/key_value.rb', line 190 def instance_of?(klass) Hash == klass || super end |
#is_a?(klass) ⇒ Boolean Also known as: kind_of?
185 186 187 |
# File 'lib/i18n/backend/key_value.rb', line 185 def is_a?(klass) Hash == klass || super end |
#nil? ⇒ Boolean
194 195 196 |
# File 'lib/i18n/backend/key_value.rb', line 194 def nil? @subtree.nil? end |