class EasyTalk::Builders::BaseBuilder

BaseBuilder is a class that provides a common structure for building schema properties

def self.collection_type?

def self.collection_type?
  false
end

def build

def build
  @valid_options.each_with_object(schema) do |(constraint_name, value), obj|
    next if @options[constraint_name].nil?
    # Use our centralized validation
    ErrorHelper.validate_constraint_value(
      property_name: property_name,
      constraint_name: constraint_name,
      value_type: value[:type],
      value: @options[constraint_name]
    )
    obj[value[:key]] = @options[constraint_name]
  end
end

def initialize(property_name, schema, options = {}, valid_options = {})

Parameters:
  • valid_options (Hash) -- The acceptable options for the given property type (default: {}).
  • options (Hash) -- The options for the builder (default: {}).
  • schema (Hash) -- A hash representing a json schema object.
  • property_name (Symbol) -- The name of the property.
def initialize(property_name, schema, options = {}, valid_options = {})
  @valid_options = COMMON_OPTIONS.merge(valid_options)
  EasyTalk.assert_valid_property_options(property_name, options, @valid_options.keys)
  @property_name = property_name
  @schema = schema
  @options = options
end