Class: PickyGuard::Policy
- Inherits:
-
Object
- Object
- PickyGuard::Policy
- Defined in:
- lib/picky_guard/policy.rb
Instance Method Summary collapse
-
#initialize(current_user) ⇒ Policy
constructor
A new instance of Policy.
- #statement_for(resource, &statement_definition) ⇒ Object
- #statements(resource_whitelist) ⇒ Object
Constructor Details
#initialize(current_user) ⇒ Policy
Returns a new instance of Policy.
8 9 10 |
# File 'lib/picky_guard/policy.rb', line 8 def initialize(current_user) # do nothing here end |
Instance Method Details
#statement_for(resource, &statement_definition) ⇒ Object
18 19 20 21 22 |
# File 'lib/picky_guard/policy.rb', line 18 def statement_for(resource, &statement_definition) proxy = StatementProxy.new(resource) proxy.instance_eval(&statement_definition) register(resource, proxy.build) end |
#statements(resource_whitelist) ⇒ Object
12 13 14 15 16 |
# File 'lib/picky_guard/policy.rb', line 12 def statements(resource_whitelist) filtered_array(resource_whitelist).map do |_resource, statement| Validator.validate_statement!(statement) end end |