Class: Assignbot::AssignerDsl
- Inherits:
-
Object
- Object
- Assignbot::AssignerDsl
- Defined in:
- lib/assignbot/dsl/assigner_dsl.rb
Overview
DSL class that will be instantiated on call of “assigner”
Instance Attribute Summary collapse
-
#target_class ⇒ Object
readonly
Returns the value of attribute target_class.
Instance Method Summary collapse
-
#initialize(target_class) ⇒ AssignerDsl
constructor
A new instance of AssignerDsl.
- #method_missing(name, *args) ⇒ Object
- #set(target_variable, source_variable, receptor) ⇒ Object
Constructor Details
#initialize(target_class) ⇒ AssignerDsl
Returns a new instance of AssignerDsl.
6 7 8 9 10 |
# File 'lib/assignbot/dsl/assigner_dsl.rb', line 6 def initialize(target_class) @target_class = target_class # assignable instance @assignable_ic = Core.get_assignable(target_class) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/assignbot/dsl/assigner_dsl.rb', line 19 def method_missing(name, *args) params = args[0] fail DslError, 'Put in hash as an argument!' unless params.is_a?(Hash) source_variable = params[:from] || params['from'] set(name, source_variable, :"#{source_variable}=") end |
Instance Attribute Details
#target_class ⇒ Object (readonly)
Returns the value of attribute target_class.
4 5 6 |
# File 'lib/assignbot/dsl/assigner_dsl.rb', line 4 def target_class @target_class end |
Instance Method Details
#set(target_variable, source_variable, receptor) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/assignbot/dsl/assigner_dsl.rb', line 12 def set(target_variable, source_variable, receptor) @assignable_ic.add_variable(:default, target_variable, source_variable, receptor) end |