Sha256: 8be076a67bab6f8a41da1b75457abd3e6958d77641ceced35cadae7de525a752

Contents?: true

Size: 597 Bytes

Versions: 8

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

require "key_vortex/constraint/base"
require "key_vortex/constraint/length"
require "key_vortex/constraint/maximum"
require "key_vortex/constraint/minimum"

class KeyVortex
  class Constraint
    def self.build(attribute, value)
      case attribute
      when :length
        KeyVortex::Constraint::Length.new(value)
      when :maximum
        KeyVortex::Constraint::Maximum.new(value)
      when :minimum
        KeyVortex::Constraint::Minimum.new(value)
      else
        raise KeyVortex::Error, "Unexpected attribute: #{attribute}"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
key-vortex-0.2.5 lib/key_vortex/constraint.rb
key-vortex-0.2.4 lib/key_vortex/constraint.rb
key-vortex-0.2.3 lib/key_vortex/constraint.rb
key-vortex-0.2.2 lib/key_vortex/constraint.rb
key-vortex-0.2.1 lib/key_vortex/constraint.rb
key-vortex-0.2.0 lib/key_vortex/constraint.rb
key-vortex-0.1.4 lib/key_vortex/constraint.rb
key-vortex-0.1.3 lib/key_vortex/constraint.rb