Class: Tuersteher::ModelSpecification

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

Instance Method Summary collapse

Constructor Details

#initialize(clazz, negation) ⇒ ModelSpecification

Returns a new instance of ModelSpecification.



426
427
428
429
# File 'lib/tuersteher.rb', line 426

def initialize clazz, negation
  clazz = clazz.name if clazz.is_a?(Class)
  @clazz, @negation = clazz, negation
end

Instance Method Details

#grant?(path_or_model, method, login_ctx) ⇒ Boolean

Returns:

  • (Boolean)


431
432
433
434
435
436
# File 'lib/tuersteher.rb', line 431

def grant? path_or_model, method, 
  m_class = path_or_model.instance_of?(Class) ? path_or_model.name : path_or_model.class.name
  rc = @clazz == m_class
  rc = !rc if @negation
  rc
end

#to_sObject



438
439
440
# File 'lib/tuersteher.rb', line 438

def to_s
  "#{@negation && 'not.'}model(#{@clazz})"
end