Sha256: 45444f063abff1748eca4d094e4102672a864de67e7357b33112503ac4828b70

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module RailsConnector

  class ObjDataFromService < ObjData
    def initialize(data)
      @data = data
    end

    def value_and_type_of(attribute_name)
      value_and_type = @data[attribute_name]

      if value_and_type.blank?
        if INTERNAL_KEYS.include?(attribute_name)
          type = type_of_internal(attribute_name)
          [default_attribute_value(type), type]
        else
          raise "Illegal attribute name #{attribute_name}"
        end
      elsif value_and_type.length == 1
        [value_and_type.first, type_of_internal(attribute_name)]
      else
        value_and_type
      end
    end

    def has_custom_attribute?(attribute_name)
      !!@data[attribute_name]
    end

    private

    internal_key_list = %w[
      last_changed
      sort_key1
      sort_key2
      sort_key3
      sort_order
      sort_type1
      sort_type2
      sort_type3
      suppress_export
      text_links
      valid_from
      valid_until
    ]

    INTERNAL_KEYS = Set.new(internal_key_list.map { |name| "_#{name}" } )

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.0.210.ed204b0 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.110.6570b45 lib/rails_connector/obj_data_from_service.rb