Class: I18nUtils::ScopeContext

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_utils.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_key, helper) ⇒ ScopeContext

Returns a new instance of ScopeContext.



34
35
36
37
38
# File 'lib/i18n_utils.rb', line 34

def initialize(base_key, helper)
  @base_key = base_key
  @helper = helper
  @hash = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



48
49
50
51
# File 'lib/i18n_utils.rb', line 48

def method_missing(name, *args, &block)
  html = @helper.capture(&block)
  @hash[name] = html
end

Instance Method Details

#t(key, opts = {}) ⇒ Object



44
45
46
# File 'lib/i18n_utils.rb', line 44

def t(key, opts = {})
  @helper.t("#{@base_key}.#{key}", opts)
end

#to_hashObject



40
41
42
# File 'lib/i18n_utils.rb', line 40

def to_hash
  @hash
end