lib/sass/rails/monkey_patches.rb in sass-rails-3.1.0.rc.2 vs lib/sass/rails/monkey_patches.rb in sass-rails-3.1.0.rc.3

- old
+ new

@@ -1,20 +1,36 @@ -require 'sprockets/railtie' +module Sass::Rails::SassContext + attr_accessor :sass_config +end -module Sprockets - class Railtie < ::Rails::Railtie +module Sass::Rails::SprocketsConfig + def self.included(base) + base.alias_method_chain :asset_environment, :sass_config + end - module SassContext - attr_accessor :sass_config - end + def asset_environment_with_sass_config(app, *args) + env = asset_environment_without_sass_config(app, *args) + env.context_class.extend(Sass::Rails::SassContext) + env.context_class.sass_config = app.config.sass + env + end +end - protected - - def asset_environment_with_sass_config(app, *args) - env = asset_environment_without_sass_config(app, *args) - env.context_class.extend(SassContext) - env.context_class.sass_config = app.config.sass - env +begin + # Before sprockets was extracted from rails + require 'sprockets/railtie' + module Sprockets + class Railtie < ::Rails::Railtie + include Sass::Rails::SprocketsConfig end - alias_method_chain :asset_environment, :sass_config + end +rescue LoadError + # After sprockets was extracted into sprockets-rails + require 'sprockets/rails/railtie' + module Sprockets + module Rails + class Railtie < ::Rails::Railtie + include Sass::Rails::SprocketsConfig + end + end end end \ No newline at end of file