Module: JobContracts::Contractable::ClassMethods

Defined in:
lib/job_contracts/concerns/contractable.rb

Instance Method Summary collapse

Instance Method Details

#add_contract(contract) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/job_contracts/concerns/contractable.rb', line 46

def add_contract(contract)
  if contract.class.const_defined?(:ContractableIncludes)
    include contract.class.const_get(:ContractableIncludes)
  end

  if contract.class.const_defined?(:ContractablePrepends)
    prepend contract.class.const_get(:ContractablePrepends)
  end

  prepend JobContracts::Contractable::Prepends

  contract.queues << queue_name.to_s if contract.queues.blank? && queue_name.present?
  contract.queues << "*" if contract.queues.blank?
  contracts << contract
end

#contractsObject



34
35
36
# File 'lib/job_contracts/concerns/contractable.rb', line 34

def contracts
  @contracts ||= Set.new
end

#on_contract_breach(value = nil, &block) ⇒ Object



38
39
40
# File 'lib/job_contracts/concerns/contractable.rb', line 38

def on_contract_breach(value = nil, &block)
  @on_contract_breach_callback = value || block
end

#on_contract_breach_callbackObject



42
43
44
# File 'lib/job_contracts/concerns/contractable.rb', line 42

def on_contract_breach_callback
  @on_contract_breach_callback ||= :contract_breached!
end