Class: SupplejackApi::InteractionModels::Record
- Inherits:
-
Object
- Object
- SupplejackApi::InteractionModels::Record
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/supplejack_api/interaction_models/record.rb
Class Method Summary collapse
- .create_find(object) ⇒ Object
- .create_search(object) ⇒ Object
-
.create_user_set(object) ⇒ Object
Creates one Interaction Model that contains set items in a set.
Class Method Details
.create_find(object) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/models/supplejack_api/interaction_models/record.rb', line 29 def self.create_find(object) return if object.nil? result = object.send(@field) result = [result] unless result.is_a? Array create(request_type: 'get', log_values: result) unless result.empty? rescue Rails.logger.warn "[RecordInteraction] Field #{field} does not exist" end |
.create_search(object) ⇒ Object
22 23 24 25 26 27 |
# File 'app/models/supplejack_api/interaction_models/record.rb', line 22 def self.create_search(object) results = object.results.map(&@field).flatten create(request_type: 'search', log_values: results) unless results.empty? rescue Rails.logger.warn "[RecordInteraction] Field #{field} does not exist" end |
.create_user_set(object) ⇒ Object
Creates one Interaction Model that contains set items in a set
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/models/supplejack_api/interaction_models/record.rb', line 41 def self.create_user_set(object) results = [] unless object.set_items.empty? object.set_items.each do |item| next if item.record.nil? record = SupplejackApi::Record.custom_find(item.record_id) if record result = record.send(@field) results << result if result end end end create(request_type: 'user_set', log_values: results.flatten) unless results.empty? rescue Rails.logger.warn "[RecordInteraction] Field #{field} does not exist" end |