Class: I18n::JS::SprocketsExtension Private
- Inherits:
-
Object
- Object
- I18n::JS::SprocketsExtension
- 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
- .call(input) ⇒ Object private
- .run(filename, source, context) ⇒ Object private
Instance Method Summary collapse
-
#initialize(filename, &block) ⇒ SprocketsExtension
constructor
private
A new instance of SprocketsExtension.
- #render(context, empty_hash_wtf) ⇒ Object private
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.
77 78 79 80 81 82 83 84 |
# File 'lib/i18n/js/engine.rb', line 77 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 67 68 69 70 71 72 73 74 75 |
# 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.(path)) } # Absolute path is required or # Sprockets assumes it's a logical path # # Calling `depend on` with an absent file # will invoke `resolve` and will throw an error in the end if I18n::JS.config_file_exists? context.depend_on(File.(I18n::JS.config_file_path)) end 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 |