Sha256: 439ce535af51af8b585eb7d62fd2ec9899432d5bd425f7c6190155e708e20804

Contents?: true

Size: 416 Bytes

Versions: 1

Compression:

Stored size: 416 Bytes

Contents

require 'super_model/error/type'

class SuperModel
  class Error
    
    class HashType < Type
      
      def self.check(object, options={})
        super
        
        raise self unless options[:required_keys].is_a?(Array) && options[:required_keys].all? { |key| object.has_key?(key) }
        
        object
      end
      
      valid_types Hash
      valid_methods :to_hash, :to_h
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
super_model-0.0.1 lib/super_model/error/hash_type.rb