Class: Protector::DSL::Meta

Inherits:
Object
  • Object
show all
Defined in:
lib/protector/dsl.rb

Overview

DSL meta storage and evaluator

Defined Under Namespace

Classes: Box

Instance Method Summary collapse

Instance Method Details

#<<(block) ⇒ Object

Register another protection block



211
212
213
# File 'lib/protector/dsl.rb', line 211

def <<(block)
  blocks << block
end

#blocksObject

Storage for protect blocks



206
207
208
# File 'lib/protector/dsl.rb', line 206

def blocks
  @blocks ||= []
end

#evaluate(adapter, model, subject, fields = [], entry = nil) ⇒ Object

Calculate protection at the context of subject

Parameters:

  • model (Class)

    The class of protected entity

  • subject (Object)

    Restriction subject

  • fields (Array<String>) (defaults to: [])

    All the fields the model has

  • entry (Object) (defaults to: nil)

    An instance of the model



221
222
223
# File 'lib/protector/dsl.rb', line 221

def evaluate(adapter, model, subject, fields=[], entry=nil)
  Box.new(adapter, model, fields, subject, entry, blocks)
end