Sha256: 30e18089ffdcf60ef54f435b61d39f5031b01ed1b6d1a38582f3104aec961e70

Contents?: true

Size: 565 Bytes

Versions: 4

Compression:

Stored size: 565 Bytes

Contents

module Rosebud
  module Validations
    @validators = {}
    
    class << self
      attr_reader :validators
    end
    
    def self.register_validator!(name, klass)
      raise(ArgumentError, 'Validation class type expected to be a subclass of Rosebud::Validator...') unless klass.ancestors.include?(Validator)
      raise(NotImplementedError, 'Validator expected validate_param to be implemented...') unless klass.instance_methods.include?(:validate_param)
      name = name.to_sym
      Errawr.register!(name)
      @validators[name] = klass
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rosebud-0.2.0 lib/rosebud/validations.rb
rosebud-0.1.2 lib/rosebud/validations.rb
rosebud-0.1.1 lib/rosebud/validations.rb
rosebud-0.1.0 lib/rosebud/validations.rb