lib/impressionist/rails_toggle.rb in impressionist-1.4.8 vs lib/impressionist/rails_toggle.rb in impressionist-1.4.9

- old
+ new

@@ -1,21 +1,25 @@ module Impressionist - # Responsability + # Responsibility # Toggles between rails > 3.1 < 4 # In order to make attr_accessible available in a rails app < 4 class RailsToggle # decides where or not to include attr_accessible def should_include? - ask_rails || false + supported_by_rails? && (not using_strong_parameters?) end private + def using_strong_parameters? + defined?(StrongParameters) + end + # returns false if rails >= 4 # true if rails < 4 - def ask_rails - ::Rails::VERSION::MAJOR.to_i >= 4 ? false : true + def supported_by_rails? + ::Rails::VERSION::MAJOR.to_i < 4 end end end