Method: LHS::Record::Endpoints::ClassMethods#sanity_check

Defined in:
lib/lhs/concerns/record/endpoints.rb

#sanity_check(new_endpoint) ⇒ Object

Prevent clashing endpoints.



45
46
47
48
49
50
51
52
# File 'lib/lhs/concerns/record/endpoints.rb', line 45

def sanity_check(new_endpoint)
  endpoints.each do |existing_endpoint|
    invalid = existing_endpoint.placeholders.sort == new_endpoint.placeholders.sort &&
      existing_endpoint.url != new_endpoint.url
    next unless invalid
    raise "Clashing endpoints! Cannot differentiate between #{existing_endpoint.url} and #{new_endpoint.url}"
  end
end