Class: Ree::Contracts::ArgContracts::Kwargs

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ree/contracts/arg_contracts/kwargs.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**contracts) ⇒ Kwargs

Returns a new instance of Kwargs.



16
17
18
19
# File 'lib/ree/contracts/arg_contracts/kwargs.rb', line 16

def initialize(**contracts)
  @contracts = contracts
  super(contracts)
end

Instance Attribute Details

#contractsObject (readonly)

Returns the value of attribute contracts.



14
15
16
# File 'lib/ree/contracts/arg_contracts/kwargs.rb', line 14

def contracts
  @contracts
end

Class Method Details

.[](**contracts) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/ree/contracts/arg_contracts/kwargs.rb', line 6

def self.[](**contracts)
  if contracts.empty?
    raise BadContractError, 'Kwargs contract should accept at least one contract'
  end

  new(**contracts)
end