Class: TaaS::Contracts

Inherits:
Object
  • Object
show all
Defined in:
lib/helper/contracts.rb

Constant Summary collapse

@@contract_hash =
{}

Class Method Summary collapse

Class Method Details

.contains?(contract_name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/helper/contracts.rb', line 18

def self.contains?(contract_name)
  @@contract_hash.keys.include?(contract_name)
end

.get_all_contractsObject



33
34
35
# File 'lib/helper/contracts.rb', line 33

def self.get_all_contracts
  return @@contract_hash
end

.get_contract(contract_name) ⇒ Object



22
23
24
25
26
# File 'lib/helper/contracts.rb', line 22

def self.get_contract(contract_name)
  return nil unless contains?(contract_name)
  contract = Contract.new @@contract_hash[contract_name]
  contract
end

.get_execution_attribute(attribute, contract_name) ⇒ Object



28
29
30
31
# File 'lib/helper/contracts.rb', line 28

def self.get_execution_attribute(attribute, contract_name)
  return nil if @@contract_hash.nil? || @@contract_hash.eql?({})
  @@contract_hash["contracts"][contract_name.to_s][attribute]
end

.is_empty?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/helper/contracts.rb', line 14

def self.is_empty?
  @@contract_hash.eql?({}) || @@contract_hash.nil?
end

.load(absolute_path) ⇒ Object



8
9
10
11
12
# File 'lib/helper/contracts.rb', line 8

def self.load(absolute_path)
  raise "File path cant be nil or empty" if (absolute_path.nil? || absolute_path.empty?)
  puts "Loading contracts file from #{absolute_path}"
  @@contract_hash = YAML.load_file(absolute_path)["contracts"]
end