Class: Comunit::Network::Handlers::PollHandler

Inherits:
Comunit::Network::Handler show all
Defined in:
app/services/comunit/network/handlers/poll_handler.rb

Overview

Handling polls

Constant Summary

Constants inherited from Comunit::Network::Handler

Comunit::Network::Handler::MAIN_HOST

Instance Attribute Summary

Attributes inherited from Comunit::Network::Handler

#data, #entity

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Comunit::Network::Handler

[], #amend, #entity_class, #initialize, #pull, #pull_and_validate, #push, relationship_data

Methods included from Sending

#headers, #rest

Methods included from Logging

#log, #log_error, #log_info, #log_warn

Constructor Details

This class inherits a constructor from Comunit::Network::Handler

Class Method Details

.ignored_attributesObject



15
16
17
18
19
20
# File 'app/services/comunit/network/handlers/poll_handler.rb', line 15

def self.ignored_attributes
  %w[
    agent_id comments_count data id poll_questions_count pollable_id
    pollable_type simple_image_id updated_at user_id
  ]
end

.permitted_attributesObject



8
9
10
11
12
13
# File 'app/services/comunit/network/handlers/poll_handler.rb', line 8

def self.permitted_attributes
  %i[
    active allow_comments anonymous_votes created_at description
    end_date exclusive ip name open_results show_on_homepage visible
  ]
end

Instance Method Details

#prepare_model_dataObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/comunit/network/handlers/poll_handler.rb', line 22

def prepare_model_data
  data = {
    id: entity.uuid,
    type: entity.class.table_name,
    attributes: attributes_for_remote,
    relationships: relationships_for_remote,
    meta: {}
  }

  data[:meta][:agent] = entity.agent&.name

  data
end