Class: PartialKs::ParentInferrer

Inherits:
Object
  • Object
show all
Defined in:
lib/partial_ks/parent_inferrer.rb

Constant Summary collapse

CannotInfer =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ ParentInferrer

Returns a new instance of ParentInferrer.



7
8
9
# File 'lib/partial_ks/parent_inferrer.rb', line 7

def initialize(table)
  @table = table
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



5
6
7
# File 'lib/partial_ks/parent_inferrer.rb', line 5

def table
  @table
end

Instance Method Details

#inferred_parent_classObject



11
12
13
14
15
16
17
18
19
# File 'lib/partial_ks/parent_inferrer.rb', line 11

def inferred_parent_class
  if table.top_level_table?
    nil
  elsif table.candidate_parent_classes.size == 1
    table.candidate_parent_classes.first
  else
    raise CannotInfer, "table has multiple candidates for parents"
  end
end