Class: Etna::Clients::Magma::RowBase

Inherits:
Object
  • Object
show all
Defined in:
lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb

Instance Method Summary collapse

Instance Method Details

#attribute_is_json?(attribute) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 55

def attribute_is_json?(attribute)
  [Etna::Clients::Magma::AttributeType::FILE,
   Etna::Clients::Magma::AttributeType::FILE_COLLECTION,
   Etna::Clients::Magma::AttributeType::IMAGE].include?(attribute.attribute_type)
end

#nil_or_empty?(value) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 72

def nil_or_empty?(value)
  value.nil? || value.empty?
end

#stripped_value(attribute, attribute_value) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb', line 61

def stripped_value(attribute, attribute_value)
  attribute_value = attribute_value&.strip

  if attribute_value &&
     ( @workflow.json_values || attribute_is_json?(attribute) ) &&
     attribute_value != @workflow.hole_value
    attribute_value = JSON.parse(attribute_value)
  end
  attribute_value
end