Class: CreateOperation
- Inherits:
-
Object
- Object
- CreateOperation
- Defined in:
- lib/create_operation.rb
Instance Method Summary collapse
-
#initialize(record_type, fields) ⇒ CreateOperation
constructor
A new instance of CreateOperation.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(record_type, fields) ⇒ CreateOperation
Returns a new instance of CreateOperation.
3 4 5 6 |
# File 'lib/create_operation.rb', line 3 def initialize(record_type, fields) @record_type = record_type @fields = fields end |
Instance Method Details
#to_json(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/create_operation.rb', line 8 def to_json( = {}) hash = {operationType: "create"} record = {recordType: @record_type} fields = {} @fields.each_pair do |k,v| fields[k] = {value: v} end record[:fields] = fields hash[:record] = record hash.to_json end |