Class: Elm::Rails::Sprockets

Inherits:
Object
  • Object
show all
Defined in:
lib/elm/rails/sprockets.rb

Constant Summary collapse

VERSION =
'3'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Sprockets

Returns a new instance of Sprockets.



22
23
24
# File 'lib/elm/rails/sprockets.rb', line 22

def initialize(options = {})
  @cache_key = [self.class.name, VERSION, options].freeze
end

Instance Attribute Details

#cache_keyObject (readonly)

Returns the value of attribute cache_key.



20
21
22
# File 'lib/elm/rails/sprockets.rb', line 20

def cache_key
  @cache_key
end

Class Method Details

.cache_keyObject



16
17
18
# File 'lib/elm/rails/sprockets.rb', line 16

def self.cache_key
  instance.cache_key
end

.call(input) ⇒ Object



12
13
14
# File 'lib/elm/rails/sprockets.rb', line 12

def self.call(input)
  instance.call(input)
end

.instanceObject



8
9
10
# File 'lib/elm/rails/sprockets.rb', line 8

def self.instance
  @instance ||= new
end

Instance Method Details

#call(input) ⇒ Object



26
27
28
29
30
# File 'lib/elm/rails/sprockets.rb', line 26

def call(input)
  context  = input[:environment].context_class.new(input)
  add_elm_dependencies(input[:filename], input[:load_path], context)
  context..merge(data: Elm::Compiler.compile(input[:filename]))
end