Class: DRep::DRepBinder
Instance Attribute Summary collapse
-
#__vars_data__ ⇒ Object
readonly
Returns the value of attribute vars_data.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #get_binding ⇒ Object
-
#initialize(environment, vars_data) ⇒ DRepBinder
constructor
A new instance of DRepBinder.
Constructor Details
#initialize(environment, vars_data) ⇒ DRepBinder
Returns a new instance of DRepBinder.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/drep/core/drep_binder.rb', line 30 def initialize(environment, vars_data) unless environment.nil? @env = environment else raise(ArgumentError, "Invalid environment", caller()) end @__vars_data__ = vars_data inject_vars() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mid, *args) ⇒ Object (private)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/drep/core/drep_binder.rb', line 74 def method_missing(mid, *args) result = '' if args.size == 0 if @__vars_data__.is_a?(Array) temp_data = nil @__vars_data__.each do |data_blob| if data_blob.is_a?(Hash) var_value = data_blob[mid] temp_data = var_value unless var_value.nil? else err('Invalid inner data blob format') end end valid temp_data do result = temp_data end else err('Invalid variables data format') end else err("Value binding failed. Invalid method call: #{mid}") end return result end |
Instance Attribute Details
#__vars_data__ ⇒ Object (readonly)
Returns the value of attribute vars_data.
28 29 30 |
# File 'lib/drep/core/drep_binder.rb', line 28 def __vars_data__ @__vars_data__ end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
26 27 28 |
# File 'lib/drep/core/drep_binder.rb', line 26 def env @env end |
Instance Method Details
#get_binding ⇒ Object
41 42 43 |
# File 'lib/drep/core/drep_binder.rb', line 41 def get_binding() return binding() end |