Class: Goldencobra::AttributeRepairService

Inherits:
Object
  • Object
show all
Defined in:
app/services/goldencobra/attribute_repair_service.rb

Class Method Summary collapse

Class Method Details

.fix_duplicate_http(model_name, id, attribute_name) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/services/goldencobra/attribute_repair_service.rb', line 4

def self.fix_duplicate_http(model_name, id, attribute_name)
  return "Not a valid model name" unless is_class?(model_name)
  return "Not a valid attribute on #{model_name}" unless is_attribute?(model_name, attribute_name)
  return "Record not found" unless record_exists?(model_name, id)

  record = "#{model_name}".constantize.where(id: id).first
  record.update_attribute(attribute_name.to_sym, repaired_url_value(record.send(attribute_name.to_sym)))
end