Sha256: 9616be5bd763de77b337e0f6487674110b2f32591c6802267b0866cdb9345223

Contents?: true

Size: 1.17 KB

Versions: 23

Compression:

Stored size: 1.17 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)
      is_custom_attribute?(attribute_name) && !!@data[attribute_name]
    end

    private

    def is_custom_attribute?(attribute_name)
      !attribute_name.starts_with?('_')
    end

    internal_key_list = %w[
      last_changed
      permalink
      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

23 entries across 23 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.9.0.3.197272233 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.3.174.51542603 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.3.115.227021242 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.3.73.75172665 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.3.2.153416031 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.3.67.110847540 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.3.1.23895778 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.2.36.82613853 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.2.7.128454143 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.1.26.236500544 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.1 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.539.93842523 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.529.114081979 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.518.30999728 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.515.34928522 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.498.46559598 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.480.261594408 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.444.171626367 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.406.131718077 lib/rails_connector/obj_data_from_service.rb
infopark_cloud_connector-6.8.0.356.19698103 lib/rails_connector/obj_data_from_service.rb