Class: Protector::DSL::Meta
- Inherits:
-
Object
- Object
- Protector::DSL::Meta
- Defined in:
- lib/protector/dsl.rb
Overview
DSL meta storage and evaluator
Defined Under Namespace
Classes: Box
Instance Method Summary collapse
-
#<<(block) ⇒ Object
Register another protection block.
-
#blocks ⇒ Object
Storage for
protectblocks. -
#evaluate(model, subject, fields = [], entry = nil) ⇒ Object
Calculate protection at the context of subject.
Instance Method Details
#<<(block) ⇒ Object
Register another protection block
191 192 193 |
# File 'lib/protector/dsl.rb', line 191 def <<(block) blocks << block end |
#blocks ⇒ Object
Storage for protect blocks
186 187 188 |
# File 'lib/protector/dsl.rb', line 186 def blocks @blocks ||= [] end |
#evaluate(model, subject, fields = [], entry = nil) ⇒ Object
Calculate protection at the context of subject
201 202 203 204 205 |
# File 'lib/protector/dsl.rb', line 201 def evaluate(model, subject, fields=[], entry=nil) raise "Unprotected entity detected: use `restrict` method to protect it." unless subject Box.new(model, fields, subject, entry, blocks) end |