Class: Copyable::CompletenessChecker

Inherits:
Object
  • Object
show all
Includes:
DeclarationStubber
Defined in:
lib/copyable/syntax_checking/completeness_checker.rb

Direct Known Subclasses

AssociationChecker, ColumnChecker

Instance Method Summary collapse

Methods included from DeclarationStubber

included

Constructor Details

#initialize(model_class) ⇒ CompletenessChecker

Returns a new instance of CompletenessChecker.



6
7
8
# File 'lib/copyable/syntax_checking/completeness_checker.rb', line 6

def initialize(model_class)
  @model_class = model_class
end

Instance Method Details

#verify!(block) ⇒ Object

an algorithm for ensuring that the expected entries are listed in a declaration – no more, and no less



12
13
14
15
16
17
18
19
20
# File 'lib/copyable/syntax_checking/completeness_checker.rb', line 12

def verify!(block)
  self.instance_eval(&block)
  expected = Set.new(expected_entries)
  provided = Set.new(provided_entries)
  missing_entries = expected - provided
  extra_entries = provided - expected
  missing_entries_found(missing_entries) if missing_entries.any?
  extra_entries_found(extra_entries) if extra_entries.any?
end