Class: Assignbot::Assigner
- Inherits:
-
Object
- Object
- Assignbot::Assigner
- Defined in:
- lib/assignbot/foundations/assigner.rb
Overview
assignable has many assigner, the default assigner is named :default. one can design assigner from params which is from JSON, or from XML. if unnamed, then use :default as name
Instance Attribute Summary collapse
-
#assignable ⇒ Object
readonly
Returns the value of attribute assignable.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#variables ⇒ Object
readonly
all variables, based on target_variable.
Class Method Summary collapse
Instance Method Summary collapse
- #add_variable(variable) ⇒ Object
- #get_variable(target_variable) ⇒ Object
-
#initialize(assignable, assigner_name) ⇒ Assigner
constructor
A new instance of Assigner.
Constructor Details
#initialize(assignable, assigner_name) ⇒ Assigner
Returns a new instance of Assigner.
19 20 21 22 23 |
# File 'lib/assignbot/foundations/assigner.rb', line 19 def initialize(assignable, assigner_name) @assignable = assignable @name = assigner_name @variables = {} end |
Instance Attribute Details
#assignable ⇒ Object (readonly)
Returns the value of attribute assignable.
7 8 9 |
# File 'lib/assignbot/foundations/assigner.rb', line 7 def assignable @assignable end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/assignbot/foundations/assigner.rb', line 8 def name @name end |
#variables ⇒ Object (readonly)
all variables, based on target_variable
10 11 12 |
# File 'lib/assignbot/foundations/assigner.rb', line 10 def variables @variables end |
Class Method Details
.canonify_name(name) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/assignbot/foundations/assigner.rb', line 12 def self.canonify_name(name) unless name.is_a?(String) || name.is_a?(Symbol) fail DslError, "Name must be either symbol or string, got: #{name}" end name.to_s.downcase.tr(' ', '_').to_sym end |
Instance Method Details
#add_variable(variable) ⇒ Object
29 30 31 |
# File 'lib/assignbot/foundations/assigner.rb', line 29 def add_variable(variable) @variables[variable.target_variable] = variable end |
#get_variable(target_variable) ⇒ Object
25 26 27 |
# File 'lib/assignbot/foundations/assigner.rb', line 25 def get_variable(target_variable) @variables[target_variable] end |