Class: TypeChecks

Inherits:
Object
  • Object
show all
Includes:
RSpec::Matchers
Defined in:
lib/brine/type_checks.rb

Overview

This will be made extensible so it can replace current domain specific check logic

Instance Method Summary collapse

Constructor Details

#initializeTypeChecks



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/brine/type_checks.rb', line 11

def initialize
  @map = {
    Object: be_a_kind_of(Hash),
    String: be_a_kind_of(String),
    Number: be_a_kind_of(Numeric),
    Integer: be_a_kind_of(Integer),
    Array: be_a_kind_of(Array),
    DateTime: be_a_kind_of(Time),
    Boolean: satisfy{|it| it == true || it == false }
  }
end

Instance Method Details

#for_type(type) ⇒ Object



23
24
25
# File 'lib/brine/type_checks.rb', line 23

def for_type(type)
  @map[type.to_sym] || raise("Unsupported type #{type}")
end