Sha256: 444d096150c8b662afc28a34d7c0c0a02b35293ef5084b218af8ad8637e74085

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

module Schema
  # Normalize all attributes of a model
  class ModelNormalizer
    def initialize
      @attribute_normalizers = {}
    end

    def add(attribute, method, options = {})
      @attribute_normalizers[attribute] ||= AttributeNormalizer.new
      @attribute_normalizers[attribute].add(method, options)
    end

    def normalize(model)
      @attribute_normalizers.each do |attribute, attribute_normalizer|
        attribute_normalizer.normalize_model_attribute(model, attribute)
      end
      model
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schema-normalize-0.1.2 lib/schema/model_normalizer.rb
schema-normalize-0.1.0 lib/schema/model_normalizer.rb