Class: Brandmaker::Job
- Inherits:
-
Object
- Object
- Brandmaker::Job
- Extended by:
- Savon::Model
- Defined in:
- lib/brandmaker/job.rb
Class Method Summary collapse
- .client ⇒ Object
-
.find(id) ⇒ Object
”desriptions“ is a brandmaker typo in API.
Instance Method Summary collapse
- #config ⇒ Object
- #id ⇒ Object
-
#initialize(data) ⇒ Job
constructor
A new instance of Job.
- #recipients ⇒ Object
- #technical_name ⇒ Object
- #variables ⇒ Object
Constructor Details
#initialize(data) ⇒ Job
Returns a new instance of Job.
21 22 23 24 |
# File 'lib/brandmaker/job.rb', line 21 def initialize data @data = data @plain_variables ||= Brandmaker::VariableCollection.new @data[:desriptions][:variable] end |
Class Method Details
.client ⇒ Object
11 12 13 |
# File 'lib/brandmaker/job.rb', line 11 def self.client Brandmaker.configuration.dse_client end |
Instance Method Details
#config ⇒ Object
34 35 36 |
# File 'lib/brandmaker/job.rb', line 34 def config Brandmaker.configuration.job_configs[self.technical_name.to_sym] or raise "Job #{self.id} is not configured, no config for #{self.technical_name}" end |
#id ⇒ Object
26 27 28 |
# File 'lib/brandmaker/job.rb', line 26 def id @data[:desriptions][:id] end |
#recipients ⇒ Object
51 52 53 54 55 |
# File 'lib/brandmaker/job.rb', line 51 def recipients val = variables.find_by_purpose(VariablePurpose::EMAIL_RECIPIENT).value val = [val] unless val.is_a? Array val end |
#technical_name ⇒ Object
30 31 32 |
# File 'lib/brandmaker/job.rb', line 30 def technical_name @data[:desriptions][:type_name] end |
#variables ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/brandmaker/job.rb', line 38 def variables available_variable_names = @plain_variables.map(&:technical_name) @variables ||= Brandmaker::VariableCollection.new( config.variables.select do |variable_config| available_variable_names.include? variable_config.name.to_s end.collect do |variable_config| variable = @plain_variables.find_by_technical_name(variable_config.name.to_s) configured_variable = variable_config.to_typed_instance(variable.data) configured_variable.config = variable_config configured_variable end, false) end |