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.



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

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



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

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

Instance Method Details

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



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

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

#to_hashObject



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

def to_hash
  @hash
end