Class: Contract

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/contract_acceptance_framework/contract.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.latest(key) ⇒ Object

Find the latest contract for a given key, by version number



12
13
14
# File 'lib/contract_acceptance_framework/contract.rb', line 12

def self.latest(key)
  for_key(key).by_version.find(:first)
end

.latest_accepted(key, acceptable) ⇒ Object

Find the latest accepted contract for a given acceptable, by key



17
18
19
# File 'lib/contract_acceptance_framework/contract.rb', line 17

def self.latest_accepted(key, acceptable)
  accepted_by(acceptable).for_key(key).by_version.find(:first)
end

Instance Method Details

#version=(version_string) ⇒ Object

Expects “1.0.2”



21
22
23
24
25
# File 'lib/contract_acceptance_framework/contract.rb', line 21

def version=(version_string) # Expects "1.0.2"
  versions = version_string.split(".")
  raise "invalid version_string" unless versions.size == 3
  self.major_version, self.minor_version, self.maintenance_version = versions
end