class Propshaft::Compilers
Attributes
Public Class Methods
Source
# File lib/propshaft/compilers.rb, line 4 def initialize(assembly) @assembly = assembly @registrations = Hash.new end
Public Instance Methods
Source
# File lib/propshaft/compilers.rb, line 18 def compilable?(asset) registrations[asset.content_type.to_s].present? end
Source
# File lib/propshaft/compilers.rb, line 22 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
Source
# File lib/propshaft/compilers.rb, line 34 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
Source
# File lib/propshaft/compilers.rb, line 9 def register(mime_type, klass) registrations[mime_type] ||= [] registrations[mime_type] << klass end