Class: MultipleMan::PayloadGenerator
- Inherits:
- 
      Object
      
        - Object
- MultipleMan::PayloadGenerator
 
- Defined in:
- lib/multiple_man/payload_generator.rb
Instance Attribute Summary collapse
- 
  
    
      #operation  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute operation. 
Instance Method Summary collapse
- #data ⇒ Object
- #id ⇒ Object
- 
  
    
      #initialize(record, operation = :create, options = {})  ⇒ PayloadGenerator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of PayloadGenerator. 
- #payload ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(record, operation = :create, options = {}) ⇒ PayloadGenerator
Returns a new instance of PayloadGenerator.
| 3 4 5 6 7 | # File 'lib/multiple_man/payload_generator.rb', line 3 def initialize(record, operation = :create, = {}) self.record = record self.operation = operation.to_s self. = end | 
Instance Attribute Details
#operation ⇒ Object
Returns the value of attribute operation.
| 34 35 36 | # File 'lib/multiple_man/payload_generator.rb', line 34 def operation @operation end | 
Instance Method Details
#data ⇒ Object
| 26 27 28 29 30 31 32 | # File 'lib/multiple_man/payload_generator.rb', line 26 def data if [:with] [:with].new(record).as_json else AttributeExtractor.new(record, [:fields]).as_json end end | 
#id ⇒ Object
| 22 23 24 | # File 'lib/multiple_man/payload_generator.rb', line 22 def id Identity.build(record, ).value end | 
#payload ⇒ Object
| 9 10 11 12 13 14 15 16 | # File 'lib/multiple_man/payload_generator.rb', line 9 def payload { type: type, operation: operation, id: id, data: data }.to_json end | 
#type ⇒ Object
| 18 19 20 | # File 'lib/multiple_man/payload_generator.rb', line 18 def type [:as] || record.class.name end |