Class: SfCli::Sf::Data::Query::BulkResultAdjuster

Inherits:
Object
  • Object
show all
Includes:
HelperMethods
Defined in:
lib/sf_cli/sf/data/query_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HelperMethods

#prepare_record_in_bulk_mode

Constructor Details

#initialize(result, model_class) ⇒ BulkResultAdjuster

Returns a new instance of BulkResultAdjuster.



30
31
32
33
# File 'lib/sf_cli/sf/data/query_helper.rb', line 30

def initialize(result, model_class)
  @result = result
  @model_class = model_class
end

Instance Attribute Details

#model_classObject (readonly)

Returns the value of attribute model_class.



28
29
30
# File 'lib/sf_cli/sf/data/query_helper.rb', line 28

def model_class
  @model_class
end

#resultObject (readonly)

Returns the value of attribute result.



28
29
30
# File 'lib/sf_cli/sf/data/query_helper.rb', line 28

def result
  @result
end

Instance Method Details

#get_return_valueObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/sf_cli/sf/data/query_helper.rb', line 35

def get_return_value
  done = result['result']['done']
  id   = result['result']['id']
  rows = result['result']['records'].each_with_object([]) do |h, a|
      record = prepare_record_in_bulk_mode(h)
      a << (model_class ? model_class.new(**record) : record)
    end

  done ? [done, rows] : [done, id]
end