class ElmSprockets::ElmProcessor

Compile Elm files for sprockets

Constants

VERSION

Public Class Methods

call(input) click to toggle source
# File lib/elm_sprockets/elm_processor.rb, line 12
def self.call(input)
  instance.call input
end
instance() click to toggle source
# File lib/elm_sprockets/elm_processor.rb, line 8
def self.instance
  @instance ||= new
end
new(options = {}) click to toggle source
# File lib/elm_sprockets/elm_processor.rb, line 16
def initialize(options = {})
  @options = options.merge(warn: true).freeze
  @opts = (Autoload::Elm::Options.with @options).freeze

  @cache_key = [
    self.class.name,
    VERSION,
    @options
  ].freeze
end

Public Instance Methods

call(input) click to toggle source
# File lib/elm_sprockets/elm_processor.rb, line 27
def call(input)
  data = input[:data]
  input[:cache].fetch(@cache_key + [input[:filename]] + [data]) do
    elm = Autoload::Elm.compiler.content(input[:data]).to_s
    { data: elm.output }
  end
end