Class: Strict::Methods::Module

Inherits:
Module
  • Object
show all
Defined in:
lib/strict/methods/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verifiable_method) ⇒ Module

Returns a new instance of Module.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/strict/methods/module.rb', line 8

def initialize(verifiable_method)
  super()

  @verifiable_method = verifiable_method
  define_method verifiable_method.name do |*args, **kwargs, &block|
    args, kwargs = verifiable_method.verify_parameters!(*args, **kwargs)

    super(*args, **kwargs, &block).tap do |value|
      verifiable_method.verify_returns!(value)
    end
  end
end

Instance Attribute Details

#verifiable_methodObject (readonly)

Returns the value of attribute verifiable_method.



6
7
8
# File 'lib/strict/methods/module.rb', line 6

def verifiable_method
  @verifiable_method
end

Instance Method Details

#inspectObject



21
22
23
# File 'lib/strict/methods/module.rb', line 21

def inspect
  "#<#{self.class} (#{verifiable_method.name})>"
end