Class: Tuersteher::ExtensionSpecification
- Inherits:
-
Object
- Object
- Tuersteher::ExtensionSpecification
- Defined in:
- lib/tuersteher.rb
Instance Method Summary collapse
- #grant?(path_or_model, method, login_ctx) ⇒ Boolean
-
#initialize(method_name, negation, expected_value = nil) ⇒ ExtensionSpecification
constructor
A new instance of ExtensionSpecification.
- #to_s ⇒ Object
Constructor Details
#initialize(method_name, negation, expected_value = nil) ⇒ ExtensionSpecification
Returns a new instance of ExtensionSpecification.
502 503 504 |
# File 'lib/tuersteher.rb', line 502 def initialize method_name, negation, expected_value=nil @method, @negation, @expected_value = method_name, negation, expected_value end |
Instance Method Details
#grant?(path_or_model, method, login_ctx) ⇒ Boolean
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/tuersteher.rb', line 506 def grant? path_or_model, method, login_ctx rc = false if path_or_model.is_a?(String) # path-variante return false if login_ctx.nil? unless login_ctx.respond_to?(@method) Tuersteher::TLogger.logger.warn("#{to_s}.grant? => false why Login-Context have not method '#{@method}'!") return false end if @expected_value rc = login_ctx.send(@method, @expected_value) else rc = login_ctx.send(@method) end else # model-variante unless path_or_model.respond_to?(@method) m_msg = path_or_model.instance_of?(Class) ? "Class '#{path_or_model.name}'" : "Object '#{path_or_model.class}'" Tuersteher::TLogger.logger.warn("#{to_s}.grant? => false why #{m_msg} have not method '#{@method}'!") return false end if @expected_value rc = path_or_model.send(@method, login_ctx, @expected_value) else rc = path_or_model.send(@method, login_ctx) end end rc = !rc if @negation rc end |
#to_s ⇒ Object
537 538 539 540 |
# File 'lib/tuersteher.rb', line 537 def to_s val_s = @expected_value.nil? ? nil : ", #{@expected_value}" "#{@negation && 'not.'}extension(:#{@method}#{val_s})" end |