Class: RVGP::Utilities::Yaml::PsychProc
- Inherits:
-
Object
- Object
- RVGP::Utilities::Yaml::PsychProc
- Defined in:
- lib/rvgp/utilities/yaml.rb
Overview
This class wraps proc types, in the yaml, and offers us the ability to execute the code in these blocks.
Instance Method Summary collapse
-
#call(params = {}) ⇒ Object
Execute the block, using the provided params as locals NOTE: We expect symbol to value here.
-
#initialize(proc_as_string) ⇒ PsychProc
constructor
Declare a proc, given the provided proc_as_string code.
Constructor Details
#initialize(proc_as_string) ⇒ PsychProc
Declare a proc, given the provided proc_as_string code
55 56 57 |
# File 'lib/rvgp/utilities/yaml.rb', line 55 def initialize(proc_as_string) @block = eval(format('proc { %s }', proc_as_string)) # rubocop:disable Security/Eval end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
77 78 79 |
# File 'lib/rvgp/utilities/yaml.rb', line 77 def method_missing(name) respond_to_missing?(name) ? @params[name] : super(name) end |
Instance Method Details
#call(params = {}) ⇒ Object
Execute the block, using the provided params as locals NOTE: We expect symbol to value here
64 65 66 67 68 69 |
# File 'lib/rvgp/utilities/yaml.rb', line 64 def call(params = {}) # params, here, act as instance variables, since we don't support named # params in the provided string, the way you typically would. @params = params @block.call end |