Class: Jerakia::Dsl::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/jerakia/dsl/policy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePolicy

Returns a new instance of Policy


21
22
# File 'lib/jerakia/dsl/policy.rb', line 21

def initialize()
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance


19
20
21
# File 'lib/jerakia/dsl/policy.rb', line 19

def instance
  @instance
end

#requestObject

Returns the value of attribute request


18
19
20
# File 'lib/jerakia/dsl/policy.rb', line 18

def request
  @request
end

Class Method Details

.evaluate(&block) ⇒ Object


12
13
14
15
16
# File 'lib/jerakia/dsl/policy.rb', line 12

def self.evaluate(&block)
  policy = new
  policy.instance_eval &block
  policy.instance
end

.evaluate_file(filename) ⇒ Object


6
7
8
9
10
# File 'lib/jerakia/dsl/policy.rb', line 6

def self.evaluate_file(filename)
  policy = new
  policy.evaluate_file(filename)
  policy.instance
end

Instance Method Details

#evaluate_file(filename) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'lib/jerakia/dsl/policy.rb', line 24

def evaluate_file(filename)
  policydata = Jerakia::Cache::File.retrieve(filename)

  unless policydata
    raise Jerakia::PolicyError, "Could not load policy file, #{filename}"
  end

  instance_eval policydata
end

#policy(name, opts = {}, &block) ⇒ Object


34
35
36
37
# File 'lib/jerakia/dsl/policy.rb', line 34

def policy(name, opts = {}, &block)
  @instance = Jerakia::Policy.new(name, opts)
  Jerakia::Dsl::Policyblock.evaluate(instance, &block)
end