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.
138 139 140 141 142 |
# File 'lib/i18n/backend/key_value.rb', line 138 def initialize(master_key, store) @master_key = master_key @store = store @subtree = nil end |
Instance Method Details
#[](key) ⇒ Object
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/i18n/backend/key_value.rb', line 148 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
144 145 146 |
# File 'lib/i18n/backend/key_value.rb', line 144 def has_key?(key) @subtree && @subtree.has_key?(key) || self[key] end |
#inspect ⇒ Object
172 173 174 |
# File 'lib/i18n/backend/key_value.rb', line 172 def inspect @subtree.inspect end |
#instance_of?(klass) ⇒ Boolean
164 165 166 |
# File 'lib/i18n/backend/key_value.rb', line 164 def instance_of?(klass) Hash == klass || super end |
#is_a?(klass) ⇒ Boolean Also known as: kind_of?
159 160 161 |
# File 'lib/i18n/backend/key_value.rb', line 159 def is_a?(klass) Hash == klass || super end |
#nil? ⇒ Boolean
168 169 170 |
# File 'lib/i18n/backend/key_value.rb', line 168 def nil? @subtree.nil? end |