Class: Spritely::Sprockets::Transformer

Inherits:
Struct
  • Object
show all
Defined in:
lib/spritely/sprockets/transformer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject

Returns the value of attribute input

Returns:

  • (Object)

    the current value of input



6
7
8
# File 'lib/spritely/sprockets/transformer.rb', line 6

def input
  @input
end

Class Method Details

.cache_keyObject



11
12
13
# File 'lib/spritely/sprockets/transformer.rb', line 11

def self.cache_key
  @cache_key ||= "#{name}:#{Spritely::VERSION}".freeze
end

.call(input) ⇒ Object



7
8
9
# File 'lib/spritely/sprockets/transformer.rb', line 7

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

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/spritely/sprockets/transformer.rb', line 15

def call
  data = cache.fetch([self.class.cache_key, input[:name], sprite_map.cache_key]) do
    sprite_map.files.each do |file|
      context.depend_on(File.dirname(file))
      context.link_asset(file)
    end

    sprite_map.save!
  end

  context..merge(data: data)
end