Sha256: f8c57ae03638cdf7d7281fb87661ab3b65a2688a85d89436d5dd74541419938c

Contents?: true

Size: 1.06 KB

Versions: 111

Compression:

Stored size: 1.06 KB

Contents

module Scrivito
  class ObjData
    def value_of(attribute_name)
      value_and_type_of(attribute_name).first
    end

    def type_of(attribute_name)
      value_and_type_of(attribute_name).second
    end

    def value_and_type_of(attribute_name)
      if attribute_name.starts_with?('_')
        [raw_value_and_type_of(attribute_name).first, nil]
      else
        raw_value_and_type_of(attribute_name)
      end
    end

    def to_h
      raise NotImplementedError, 'implement in subclass'
    end

    def raw_value_and_type_of(attribute_name)
      raise NotImplementedError, "implement in subclass"
    end

    def attribute_names
      raise NotImplementedError, "implement in subclass"
    end

    def ==(other)
      return false unless other.is_a?(ObjData)

      attrs = self.attribute_names | other.attribute_names
      attrs.reject! { |attribute_name| attribute_name.starts_with?('_') }
      attrs += %w[_path _permalink _widget_pool]

      attrs.all? do |attribute_name|
        value_of(attribute_name) == other.value_of(attribute_name)
      end
    end
  end
end

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
scrivito_sdk-0.71.0 lib/scrivito/obj_data.rb
scrivito_sdk-0.71.0.rc2 lib/scrivito/obj_data.rb
scrivito_sdk-0.71.0.rc1 lib/scrivito/obj_data.rb
scrivito_sdk-0.70.0 lib/scrivito/obj_data.rb
scrivito_sdk-0.70.0.rc3 lib/scrivito/obj_data.rb
scrivito_sdk-0.70.0.rc2 lib/scrivito/obj_data.rb
scrivito_sdk-0.70.0.rc1 lib/scrivito/obj_data.rb
scrivito_sdk-0.66.0 lib/scrivito/obj_data.rb
scrivito_sdk-0.66.0.rc2 lib/scrivito/obj_data.rb
scrivito_sdk-0.65.2 lib/scrivito/obj_data.rb
scrivito_sdk-0.66.0.rc1 lib/scrivito/obj_data.rb