Module: TypeEnforcer

Overview

rubocop:disable all

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



7
8
9
10
# File 'lib/type_enforcer.rb', line 7

def self.extended(base)
  base.instance_variable_set(:@type_enforcements, {})
  base.instance_variable_set(:@applying_enforcement, false)
end

Instance Method Details

#__(method_name, param_types, return_type = nil, level: 1, skip: []) ⇒ Object



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

def __(method_name, param_types, return_type = nil, level: 1, skip: [])
  return unless type_enforcement_enabled?

  @type_enforcements[method_name] = {
    params: param_types,
    return: return_type,
    level: level,
    skip: skip
  }
end

#method_added(method_name) ⇒ Object



23
24
25
26
# File 'lib/type_enforcer.rb', line 23

def method_added(method_name)
  super
  apply_enforcement(method_name)
end