Class: Elf::Policy::PolicyBuilder

Inherits:
Object
  • Object
show all
Includes:
BuilderHelper
Defined in:
lib/mithril/policy/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BuilderHelper

#section_start

Constructor Details

#initializePolicyBuilder

Returns a new instance of PolicyBuilder.



309
310
311
312
# File 'lib/mithril/policy/dsl.rb', line 309

def initialize()
  @policy = Policy.new()
  @every_state = []
end

Instance Attribute Details

#policyObject (readonly)

Returns the value of attribute policy.



308
309
310
# File 'lib/mithril/policy/dsl.rb', line 308

def policy
  @policy
end

Instance Method Details

#every_state(&block) ⇒ Object



327
328
329
330
# File 'lib/mithril/policy/dsl.rb', line 327

def every_state(&block)
  @every_state << block
  @policy.state
end

#start(name) ⇒ Object



331
332
333
# File 'lib/mithril/policy/dsl.rb', line 331

def start(name)
  @policy.start = name
end

#state(name, &block) ⇒ Object



313
314
315
316
317
318
319
320
# File 'lib/mithril/policy/dsl.rb', line 313

def state(name, &block)
  StateBuilder.new(name,name,@policy).tap {|x|
    x.instance_eval(&block)
    @every_state.each {|b|
      x.instance_eval(b)
    }
  }
end

#tag(name, &block) ⇒ Object



321
322
323
324
325
326
# File 'lib/mithril/policy/dsl.rb', line 321

def tag(name, &block)
  policy.tags[name] ||= []
  x =TagBuilder.new(@policy)
  x.instance_eval(&block)
  policy.tags[name] += x.ranges
end