Module: Intercom::ApiOperations::Save::ClassMethods

Defined in:
lib/intercom/api_operations/save.rb

Constant Summary collapse

PARAMS_NOT_PROVIDED =
Object.new

Instance Method Summary collapse

Instance Method Details

#create(params = PARAMS_NOT_PROVIDED) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/intercom/api_operations/save.rb', line 9

def create(params = PARAMS_NOT_PROVIDED)
  if self.ancestors.include?(Intercom::Contact) && params == PARAMS_NOT_PROVIDED
    params = Hash.new
  elsif params == PARAMS_NOT_PROVIDED
    raise ArgumentError, '.create requires 1 parameter'
  end

  instance = self.new(params)
  instance.mark_fields_as_changed!(params.keys)
  instance.save
end