Module: Sparsify::GuardMethods

Included in:
Sparsify
Defined in:
lib/sparsify/guard_methods.rb

Overview

Methods to ensure Sparsify isn’t mixed into nonsensical things

Instance Method Summary collapse

Instance Method Details

#extended(base) ⇒ Object

Sparsify can be extended into instances of Hash

Parameters:

  • base (Hash)


8
9
10
11
12
# File 'lib/sparsify/guard_methods.rb', line 8

def extended(base)
  unless base.is_a? Hash
    raise ArgumentError, "<#{base.inspect}> is not a Hash!"
  end
end

#included(base) ⇒ Object

Sparsigy can be included into implementations of Hash

Parameters:

  • base (Hash.class)


16
17
18
19
20
# File 'lib/sparsify/guard_methods.rb', line 16

def included(base)
  unless base <= Hash
    raise ArgumentError, "<#{base.inspect} does not inherit Hash"
  end
end