Class: Elf::Policy::PolicyBuilder
- Inherits:
-
Object
- Object
- Elf::Policy::PolicyBuilder
- Includes:
- BuilderHelper
- Defined in:
- lib/mithril/policy/dsl.rb
Instance Attribute Summary collapse
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
Instance Method Summary collapse
- #every_state(&block) ⇒ Object
-
#initialize ⇒ PolicyBuilder
constructor
A new instance of PolicyBuilder.
- #start(name) ⇒ Object
- #state(name, &block) ⇒ Object
- #tag(name, &block) ⇒ Object
Methods included from BuilderHelper
Constructor Details
#initialize ⇒ PolicyBuilder
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
#policy ⇒ Object (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.[name] ||= [] x =TagBuilder.new(@policy) x.instance_eval(&block) policy.[name] += x.ranges end |