Class: Ansible::Ruby::DslBuilders::FileLevel
- Defined in:
- lib/ansible/ruby/dsl_builders/file_level.rb
Instance Method Summary collapse
- #_process_method(id) ⇒ Object
-
#_result ⇒ Object
any order/lazy result :reek:NilCheck - when nil is the simplest way to check this.
- #handler(name, &block) ⇒ Object
-
#initialize ⇒ FileLevel
constructor
A new instance of FileLevel.
- #play(name = nil, &block) ⇒ Object
- #task(name, &block) ⇒ Object
Methods inherited from Base
#jinja, #method_missing, #respond_to_missing?
Constructor Details
#initialize ⇒ FileLevel
Returns a new instance of FileLevel.
9 10 11 12 13 |
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 9 def initialize @plays = [] @tasks_builder = nil @context = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ansible::Ruby::DslBuilders::Base
Instance Method Details
#_process_method(id) ⇒ Object
53 54 55 |
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 53 def _process_method(id, *) no_method_error id, 'Only valid options are [:task, :handler, :play]' end |
#_result ⇒ Object
any order/lazy result :reek:NilCheck - when nil is the simplest way to check this
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 39 def _result case @context when :playbook # TODO: Add a playbook DSL and do this like tasks Models::Playbook.new plays: @plays when :tasks, :handlers @tasks_builder._result when nil raise 'Must supply at least 1 handler/task/play!' else raise "Unknown context #{@context}" end end |
#handler(name, &block) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/ansible/ruby/dsl_builders/file_level.rb', line 30 def handler(name, &block) _validate_context :handlers @context = :handlers @tasks_builder ||= Tasks.new(:handlers) @tasks_builder.handler name, &block end |