Exception: Trample::LookupNotFoundError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/trample/lookup_not_found.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition, lookup_results, corresponding_lookup) ⇒ LookupNotFoundError

Returns a new instance of LookupNotFoundError.



6
7
8
9
10
11
# File 'lib/trample/lookup_not_found.rb', line 6

def initialize(condition, lookup_results, corresponding_lookup)
  @condition = condition
  @lookup_results = lookup_results
  @corresponding_lookup = corresponding_lookup
  super(message)
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



4
5
6
# File 'lib/trample/lookup_not_found.rb', line 4

def condition
  @condition
end

#corresponding_lookupObject (readonly)

Returns the value of attribute corresponding_lookup.



4
5
6
# File 'lib/trample/lookup_not_found.rb', line 4

def corresponding_lookup
  @corresponding_lookup
end

#lookup_resultsObject (readonly)

Returns the value of attribute lookup_results.



4
5
6
# File 'lib/trample/lookup_not_found.rb', line 4

def lookup_results
  @lookup_results
end

Instance Method Details

#criteria_keysObject



25
26
27
# File 'lib/trample/lookup_not_found.rb', line 25

def criteria_keys
  @criteria_keys ||= Array(condition.values).map { |l| l[:key] }.sort
end

#diffObject



33
34
35
# File 'lib/trample/lookup_not_found.rb', line 33

def diff
  criteria_keys - lookup_keys
end

#lookup_keysObject



29
30
31
# File 'lib/trample/lookup_not_found.rb', line 29

def lookup_keys
  @lookup_keys ||= Array(lookup_results).map {|l| l[:key] }.sort
end

#messageObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/trample/lookup_not_found.rb', line 13

def message
  msg = <<-MSG.strip_heredoc
        No corresponding lookup found for condition #{condition.name}

        Corresponding Lookup Result: #{ corresponding_lookup }

        Criteria Keys:        #{ criteria_keys.join(", ") }
        Lookup Result Keys:   #{ lookup_keys.join(", ") }
        Missing:              #{ diff.join(", ") }
        MSG
end