Class: InformantCommon::Event::FormSubmission

Inherits:
Base
  • Object
show all
Defined in:
lib/informant-common/event/form_submission.rb

Direct Known Subclasses

MockFormSubmission

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#authorization_header_value, authorization_header_value, #endpoint, net_http_start_arguments, #net_http_start_arguments, #post_request

Instance Attribute Details

#handlerObject

Returns the value of attribute handler.



4
5
6
# File 'lib/informant-common/event/form_submission.rb', line 4

def handler
  @handler
end

Class Method Details

.endpointObject



32
33
34
# File 'lib/informant-common/event/form_submission.rb', line 32

def self.endpoint
  @endpoint ||= URI("#{InformantCommon::Config.collector_host}/v2/form-submissions")
end

Instance Method Details

#as_json(*_args) ⇒ Object



21
22
23
24
25
26
# File 'lib/informant-common/event/form_submission.rb', line 21

def as_json(*_args)
  {
    name: handler,
    models: models.map(&:as_json)
  }
end

#modelsObject



13
14
15
# File 'lib/informant-common/event/form_submission.rb', line 13

def models
  @models ||= []
end

#process_model(model) ⇒ Object



6
7
8
9
10
11
# File 'lib/informant-common/event/form_submission.rb', line 6

def process_model(model)
  return if model.nil? || Config.exclude_models.include?(model.name)

  models.reject! { |container| container.id == model.id }
  models << model
end

#to_json(*_args) ⇒ Object



28
29
30
# File 'lib/informant-common/event/form_submission.rb', line 28

def to_json(*_args)
  as_json.to_json
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/informant-common/event/form_submission.rb', line 17

def valid?
  models.any?
end