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-1.18.0 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.18.0.rc1 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.17.0 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.17.0.rc3 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.17.0.rc2 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.17.0.rc1 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.16.0 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.16.0.rc2 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.16.0.rc1 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.15.0 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.15.0.rc2 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.15.0.rc1 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.14.0 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.14.0.rc3 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.14.0.rc2 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.14.0.rc1 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.13.0 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.13.0.rc2 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.13.0.rc1 app/cms/scrivito/obj_data.rb
scrivito_sdk-1.12.0 app/cms/scrivito/obj_data.rb