Class: PickyGuard::StatementProxy

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

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ StatementProxy

Returns a new instance of StatementProxy.



7
8
9
10
11
# File 'lib/picky_guard/statement_proxy.rb', line 7

def initialize(resource)
  @resource = resource
  allow
  instance_resource
end

Instance Method Details

#actions(actions) ⇒ Object

rubocop:disable Style/TrivialAccessors



22
23
24
# File 'lib/picky_guard/statement_proxy.rb', line 22

def actions(actions)
  @actions = actions
end

#allowObject



13
14
15
# File 'lib/picky_guard/statement_proxy.rb', line 13

def allow
  @effect = PickyGuard::Statement::EFFECT_ALLOW
end

#buildObject



46
47
48
49
# File 'lib/picky_guard/statement_proxy.rb', line 46

def build
  validate!
  build_statement
end

#class_resourceObject



35
36
37
# File 'lib/picky_guard/statement_proxy.rb', line 35

def class_resource
  @resource_type = PickyGuard::Statement::RESOURCE_TYPE_CLASS
end

#conditions(conditions) ⇒ Object



26
27
28
# File 'lib/picky_guard/statement_proxy.rb', line 26

def conditions(conditions)
  @conditions = conditions
end

#denyObject



17
18
19
# File 'lib/picky_guard/statement_proxy.rb', line 17

def deny
  @effect = PickyGuard::Statement::EFFECT_DENY
end

#instance_resourceObject

rubocop:enable Style/TrivialAccessors



31
32
33
# File 'lib/picky_guard/statement_proxy.rb', line 31

def instance_resource
  @resource_type = PickyGuard::Statement::RESOURCE_TYPE_INSTANCE
end

#validate!Object



39
40
41
42
43
44
# File 'lib/picky_guard/statement_proxy.rb', line 39

def validate!
  Validator.validate_effect!(@effect)
  Validator.validate_all_actions!(@actions)
  Validator.validate_resource_class!(@resource)
  Validator.validate_conditions!(@conditions) if instance_resource?
end