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.



96
97
98
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 96

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

Instance Attribute Details

#failed_testsObject (readonly)

Returns the value of attribute failed_tests.



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

def failed_tests
  @failed_tests
end

#usersObject (readonly)

Returns the value of attribute users.



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

def users
  @users
end

Instance Method Details

#assert(ok) ⇒ Object



111
112
113
114
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 111

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

#check(engine, users) ⇒ Object



100
101
102
103
104
105
106
107
108
109
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 100

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)


116
117
118
119
120
# File 'lib/declarative_authorization/development_support/change_supporter.rb', line 116

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