module Protector::DSL::Base
Public Instance Methods
protector_subject()
click to toggle source
Property accessor that makes sure you don’t use subject on a non-protected model
# File lib/protector/dsl.rb, line 289 def protector_subject unless protector_subject? fail "Unprotected entity detected for '#{self.class}': use `restrict` method to protect it." end @protector_subject end
protector_subject?()
click to toggle source
Checks if model was restricted
# File lib/protector/dsl.rb, line 314 def protector_subject? @protector_subject_set == true && !Thread.current[:protector_disabled] end
restrict!(subject=nil)
click to toggle source
Assigns restriction subject
@param [Object] subject Subject to restrict against
# File lib/protector/dsl.rb, line 300 def restrict!(subject=nil) @protector_subject = subject @protector_subject_set = true self end
unrestrict!()
click to toggle source
Clears restriction subject
# File lib/protector/dsl.rb, line 307 def unrestrict! @protector_subject = nil @protector_subject_set = false self end