Sha256: 9316114b427ada5c6aeac4821dcea57bc9edcafd52299b49c1d962e6efc53388
Contents?: true
Size: 1010 Bytes
Versions: 4
Compression:
Stored size: 1010 Bytes
Contents
class Propshaft::Compilers attr_reader :registrations, :assembly def initialize(assembly) @assembly = assembly @registrations = Hash.new end def register(mime_type, klass) registrations[mime_type] ||= [] registrations[mime_type] << klass end def any? registrations.any? end def compilable?(asset) registrations[asset.content_type.to_s].present? end def compile(asset) if relevant_registrations = registrations[asset.content_type.to_s] asset.content.dup.tap do |input| relevant_registrations.each do |compiler| input.replace compiler.new(assembly).compile(asset, input) end end else asset.content end end def referenced_by(asset) Set.new.tap do |references| if relevant_registrations = registrations[asset.content_type.to_s] relevant_registrations.each do |compiler| references.merge compiler.new(assembly).referenced_by(asset) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
propshaft-1.1.0 | lib/propshaft/compilers.rb |
propshaft-1.0.1 | lib/propshaft/compilers.rb |
propshaft-1.0.0 | lib/propshaft/compilers.rb |
propshaft-0.9.1 | lib/propshaft/compilers.rb |