Module: Protector::DSL::Base
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/protector/dsl.rb
Instance Method Summary collapse
-
#protector_subject ⇒ Object
Property accessor that makes sure you don't use subject on a non-protected model.
-
#protector_subject? ⇒ Boolean
Checks if model was restricted.
-
#restrict!(subject = nil) ⇒ Object
Assigns restriction subject.
-
#unrestrict! ⇒ Object
Clears restriction subject.
Instance Method Details
#protector_subject ⇒ Object
Property accessor that makes sure you don't use subject on a non-protected model
264 265 266 267 268 269 270 |
# File 'lib/protector/dsl.rb', line 264 def protector_subject unless protector_subject? raise "Unprotected entity detected for '#{self.class}': use `restrict` method to protect it." end @protector_subject end |
#protector_subject? ⇒ Boolean
Checks if model was restricted
289 290 291 |
# File 'lib/protector/dsl.rb', line 289 def protector_subject? @protector_subject_set == true && !Thread.current[:protector_disabled] end |
#restrict!(subject = nil) ⇒ Object
Assigns restriction subject
275 276 277 278 279 |
# File 'lib/protector/dsl.rb', line 275 def restrict!(subject=nil) @protector_subject = subject @protector_subject_set = true self end |
#unrestrict! ⇒ Object
Clears restriction subject
282 283 284 285 286 |
# File 'lib/protector/dsl.rb', line 282 def unrestrict! @protector_subject = nil @protector_subject_set = false self end |