Module: AcceptsNestedAttributesForPublicId

Defined in:
lib/accepts_nested_attributes_for_public_id/version.rb,
lib/accepts_nested_attributes_for_public_id/method_contracts.rb

Constant Summary collapse

VERSION =
"1.0.1".freeze
ALLOWED_VIOLATIONS =
[
  ->(method) { Rails::VERSION::MAJOR < 7 && method.name == :assign_nested_attributes_for_collection_association }, ### small change from `map.compact` to `filter_map`
  ->(method) { Rails::VERSION::MAJOR < 7 && method.name == :fields_for_with_nested_attributes }, ### small syntax change
]

Class Method Summary collapse

Class Method Details

.verify_method_contract!(method, contract) ⇒ Object



7
8
9
10
11
12
# File 'lib/accepts_nested_attributes_for_public_id/method_contracts.rb', line 7

def verify_method_contract!(method, contract)
  if method.source.strip.gsub(/^\s*/, "") != contract.strip.gsub(/^\s*/, "")
    return if ALLOWED_VIOLATIONS.any?{|x| x.call(method) }
    raise RuntimeError.new("Method definition contract violated for '#{method.owner}##{method.name}', cannot apply patch for accepts_nested_attributes_for_public_id")
  end
end