Class: Euston::MappingMap

Inherits:
Array
  • Object
show all
Defined in:
lib/euston/aggregate_command_map.rb

Instance Method Summary collapse

Instance Method Details

#any_mapping_matching?(spec) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/euston/aggregate_command_map.rb', line 29

def any_mapping_matching?(spec)
  any? { |c| (c.keys & spec.keys).all? {|k| c[k] == spec[k]} }
end

#find_mapping_for_type(type) ⇒ Object



25
26
27
# File 'lib/euston/aggregate_command_map.rb', line 25

def find_mapping_for_type(type)
  find { |c| c[:type] == type }
end

#find_mapping_matching(spec) ⇒ Object



33
34
35
# File 'lib/euston/aggregate_command_map.rb', line 33

def find_mapping_matching(spec)
  find {|c| (c.keys & spec.keys).all? {|k| c[k] == spec[k]} }
end

#has_mapping?(value, key = :type) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/euston/aggregate_command_map.rb', line 21

def has_mapping?(value, key = :type)
  self.any? { |m| m[key] == value }
end

#push_if_unique(mapping, type) ⇒ Object



37
38
39
40
# File 'lib/euston/aggregate_command_map.rb', line 37

def push_if_unique(mapping, type)
  return if has_mapping?(type)
  push(mapping)
end