Sha256: 54ebd532e09856b6806a0a4705627223e5deaab97c071d7be549e7a2523d19de

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  class CustomizableConfig
    attr_reader :customizable_model, :types

    def initialize(customizable_model)
      @customizable_model = customizable_model
    end

    def types=(value)
      invalid_types = value - ActiveFields.config.type_names
      if invalid_types.any?
        raise ArgumentError, "undefined ActiveFields types provided for #{customizable_model}: #{invalid_types}"
      end

      @types = value
    end

    def types_class_names
      ActiveFields.config.fields.values_at(*types)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_fields-1.1.0 lib/active_fields/customizable_config.rb
active_fields-1.0.0 lib/active_fields/customizable_config.rb