Class: Jerakia::Dsl::Policy
- Inherits:
-
Object
- Object
- Jerakia::Dsl::Policy
- Defined in:
- lib/jerakia/dsl/policy.rb
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#request ⇒ Object
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate_file(filename) ⇒ Object
-
#initialize(req) ⇒ Policy
constructor
A new instance of Policy.
- #policy(name, opts = {}, &block) ⇒ Object
Constructor Details
#initialize(req) ⇒ Policy
Returns a new instance of Policy.
20 21 22 |
# File 'lib/jerakia/dsl/policy.rb', line 20 def initialize(req) @request=req end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
18 19 20 |
# File 'lib/jerakia/dsl/policy.rb', line 18 def instance @instance end |
#request ⇒ Object
Returns the value of attribute request.
17 18 19 |
# File 'lib/jerakia/dsl/policy.rb', line 17 def request @request end |
Class Method Details
.evaluate(request, &block) ⇒ Object
11 12 13 14 15 |
# File 'lib/jerakia/dsl/policy.rb', line 11 def self.evaluate(request, &block) policy = new(request) policy.instance_eval &block policy.instance end |
.evaluate_file(filename, request) ⇒ Object
5 6 7 8 9 |
# File 'lib/jerakia/dsl/policy.rb', line 5 def self.evaluate_file(filename, request) policy = new(request) policy.evaluate_file(filename) policy.instance end |
Instance Method Details
#evaluate_file(filename) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/jerakia/dsl/policy.rb', line 24 def evaluate_file(filename) begin policydata=Jerakia.filecache(filename) rescue Jerakia::Error => e raise Jerakia::PolicyError, "Could not load policy file, #{e.}" end instance_eval policydata end |