Class: Authorization::DevelopmentSupport::ChangeSupporter::ApproachChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/declarative_authorization/development_support/change_supporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(analyzer, tests) ⇒ ApproachChecker

Returns a new instance of ApproachChecker.



73
74
75
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 73

def initialize (analyzer, tests)
  @analyzer, @tests = analyzer, tests
end

Instance Attribute Details

#failed_testsObject (readonly)

Returns the value of attribute failed_tests.



71
72
73
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 71

def failed_tests
  @failed_tests
end

#usersObject (readonly)

Returns the value of attribute users.



71
72
73
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 71

def users
  @users
end

Instance Method Details

#assert(ok) ⇒ Object



88
89
90
91
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 88

def assert (ok)
  @failed_tests << Test.new(*([!@current_permit_result] + @current_test_args)) unless ok
  @ok &&= ok
end

#check(engine, users) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 77

def check (engine, users)
  @current_engine = engine
  @failed_tests = []
  @current_test_args = nil
  @current_permit_result = nil
  @users = users
  @ok = true
  instance_eval(&@tests)
  @ok
end

#permit?(*args) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
96
97
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 93

def permit? (*args)
  @current_test_args = args
  @current_permit_result = @current_engine.permit?(
      *(args[0...-1] + [args.last.merge(:skip_attribute_test => true)]))
end