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
protect
blocks. -
#evaluate(subject, entry = nil) ⇒ Object
Calculate protection at the context of subject.
- #fields ⇒ Object
-
#initialize(adapter, model, &fields_proc) ⇒ Meta
constructor
A new instance of Meta.
Constructor Details
#initialize(adapter, model, &fields_proc) ⇒ Meta
Returns a new instance of Meta.
245 246 247 248 249 |
# File 'lib/protector/dsl.rb', line 245 def initialize(adapter, model, &fields_proc) @adapter = adapter @model = model @fields_proc = fields_proc end |
Instance Method Details
#<<(block) ⇒ Object
Register another protection block
261 262 263 |
# File 'lib/protector/dsl.rb', line 261 def <<(block) blocks << block end |
#blocks ⇒ Object
Storage for protect
blocks
256 257 258 |
# File 'lib/protector/dsl.rb', line 256 def blocks @blocks ||= [] end |
#evaluate(subject, entry = nil) ⇒ Object
Calculate protection at the context of subject
269 270 271 |
# File 'lib/protector/dsl.rb', line 269 def evaluate(subject, entry=nil) Box.new(@adapter, @model, fields, subject, entry, blocks) end |
#fields ⇒ Object
251 252 253 |
# File 'lib/protector/dsl.rb', line 251 def fields @fields ||= @fields_proc.call end |