Class: Nexaas::Async::Collector::AsyncResource

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/nexaas/async/collector/async_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AsyncResource

Returns a new instance of AsyncResource.



15
16
17
18
19
# File 'app/models/nexaas/async/collector/async_resource.rb', line 15

def initialize(opts={})
  opts.each do |key, value|
    self.send("#{key}=", value)
  end
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def args
  @args
end

#class_methodObject

Returns the value of attribute class_method.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def class_method
  @class_method
end

#class_nameObject

Returns the value of attribute class_name.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def class_name
  @class_name
end

#collect_idObject

Returns the value of attribute collect_id.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def collect_id
  @collect_id
end

#fileObject

Returns the value of attribute file.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def file
  @file
end

#instrumentation_contextObject

Returns the value of attribute instrumentation_context.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def instrumentation_context
  @instrumentation_context
end

#scope_idObject

Returns the value of attribute scope_id.



8
9
10
# File 'app/models/nexaas/async/collector/async_resource.rb', line 8

def scope_id
  @scope_id
end

Instance Method Details

#save!Object



21
22
23
24
25
# File 'app/models/nexaas/async/collector/async_resource.rb', line 21

def save!
  initialize_collect_id
  raise "Nexaas::Async::Collector: invalid fields #{errors.messages.keys.join(', ')}" unless valid?
  AsyncResourceJob.perform_async(sliced_attributes) 
end

#sliced_attributesObject



27
28
29
30
31
32
33
# File 'app/models/nexaas/async/collector/async_resource.rb', line 27

def sliced_attributes
  {
    scope_id: scope_id, class_name: class_name, class_method: class_method,
    args: args, file: file, collect_id: collect_id,
    instrumentation_context: instrumentation_context
  }.reject { |_,v| v.nil? }
end