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
279 280 281 282 283 284 285 |
# File 'lib/protector/dsl.rb', line 279 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? ⇒ Boolean
Checks if model was restricted
304 305 306 |
# File 'lib/protector/dsl.rb', line 304 def protector_subject? @protector_subject_set == true && !Thread.current[:protector_disabled] end |
#restrict!(subject = nil) ⇒ Object
Assigns restriction subject
290 291 292 293 294 |
# File 'lib/protector/dsl.rb', line 290 def restrict!(subject=nil) @protector_subject = subject @protector_subject_set = true self end |
#unrestrict! ⇒ Object
Clears restriction subject
297 298 299 300 301 |
# File 'lib/protector/dsl.rb', line 297 def unrestrict! @protector_subject = nil @protector_subject_set = false self end |