Class: HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef::DslParser
- Inherits:
-
Object
- Object
- HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef::DslParser
- Defined in:
- lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
Overview
Small class that can get a Ruby DSL file and return all DSL calls that have been made to it
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
List of calls made by parsing the source file Array.
Instance Method Summary collapse
-
#initialize(calls = []) ⇒ DslParser
constructor
Constructor.
- #method_missing(method_name, *args, &block) ⇒ Object
-
#parse(source) ⇒ Object
Parse a file and get all its DSL calls.
Constructor Details
#initialize(calls = []) ⇒ DslParser
Constructor
- Parameters
-
calls (Array): List of calls to complement [default = []]
20 21 22 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb', line 20 def initialize(calls = []) @calls = calls end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb', line 32 def method_missing(method_name, *args, &block) sub_calls = [] @calls << { method: method_name, args: args, block: block, calls_on_result: sub_calls } DslParser.new(sub_calls) end |
Instance Attribute Details
#calls ⇒ Object (readonly)
List of calls made by parsing the source file Array
14 15 16 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb', line 14 def calls @calls end |
Instance Method Details
#parse(source) ⇒ Object
Parse a file and get all its DSL calls
- Parameters
-
source (String): File to parse
28 29 30 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb', line 28 def parse(source) instance_eval(File.read(source)) end |