Module: Contracts::Attrs

Included in:
Contracts
Defined in:
lib/contracts-ruby2/lib/contracts/attrs.rb,
lib/contracts-ruby3/lib/contracts/attrs.rb

Instance Method Summary collapse

Instance Method Details

#attr_accessor_with_contract(*names, contract) ⇒ Object



17
18
19
20
# File 'lib/contracts-ruby2/lib/contracts/attrs.rb', line 17

def attr_accessor_with_contract(*names, contract)
  attr_reader_with_contract(*names, contract)
  attr_writer_with_contract(*names, contract)
end

#attr_reader_with_contract(*names, contract) ⇒ Object



3
4
5
6
7
8
# File 'lib/contracts-ruby2/lib/contracts/attrs.rb', line 3

def attr_reader_with_contract(*names, contract)
  names.each do |name|
    Contract Contracts::None => contract
    attr_reader(name)
  end
end

#attr_writer_with_contract(*names, contract) ⇒ Object



10
11
12
13
14
15
# File 'lib/contracts-ruby2/lib/contracts/attrs.rb', line 10

def attr_writer_with_contract(*names, contract)
  names.each do |name|
    Contract contract => contract
    attr_writer(name)
  end
end