Class: I18n::JS::SprocketsExtension Private

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/js/engine.rb,
lib/i18n/js/engine.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, &block) ⇒ SprocketsExtension

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SprocketsExtension.



51
52
53
54
# File 'lib/i18n/js/engine.rb', line 51

def initialize(filename, &block)
  @filename = filename
  @source   = block.call
end

Class Method Details

.call(input) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



68
69
70
71
72
73
74
75
# File 'lib/i18n/js/engine.rb', line 68

def self.call(input)
  filename = input[:filename]
  source   = input[:data]
  context  = input[:environment].context_class.new(input)

  result = run(filename, source, context)
  context..merge(data: result)
end

.run(filename, source, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
63
64
65
66
# File 'lib/i18n/js/engine.rb', line 60

def self.run(filename, source, context)
  if context.logical_path == "i18n/filtered"
    ::I18n.load_path.each { |path| context.depend_on(File.expand_path(path)) }
  end

  source
end

Instance Method Details

#render(context, empty_hash_wtf) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
# File 'lib/i18n/js/engine.rb', line 56

def render(context, empty_hash_wtf)
  self.class.run(@filename, @source, context)
end