Class: Postspec::FoxFrame

Inherits:
Frame
  • Object
show all
Defined in:
lib/postspec/frame.rb

Instance Attribute Summary collapse

Attributes inherited from Frame

#anchors, #ids, #parent, #pop_sql, #postspec, #push_sql, #search_path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Frame

#dump, #schema, #transaction?

Constructor Details

#initialize(parent, search_path, fox, data, push_sql) ⇒ FoxFrame

Note FoxFrame::new computes the fox object. It has four arguments instead of the five below



89
90
91
92
93
# File 'lib/postspec/frame.rb', line 89

def initialize(parent, search_path, fox, data, push_sql)
  @fox = fox
  @data = data
  super(parent.postspec, parent, search_path, push_sql, nil, fox.ids, fox.anchors)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



84
85
86
# File 'lib/postspec/frame.rb', line 84

def data
  @data
end

#foxObject (readonly)

Returns the value of attribute fox.



83
84
85
# File 'lib/postspec/frame.rb', line 83

def fox
  @fox
end

Class Method Details

.new(parent, search_path, type, files) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/postspec/frame.rb', line 95

def self.new(parent, search_path, type, files)
  fox_signature = self.fox_signature(files)
  fox = @fox_pool[fox_signature] ||= FixtureFox::Fox.new(type, files, schema: search_path.last)

  # The IDs for the data signature is the minimal set of external IDs used by the Fox object
  ids = fox.tables.map { |table| (id = parent.ids[table.uid]) ? [table.uid, id] : nil }.compact.to_h
  data_signature = self.data_signature(fox_signature, ids, fox.referenced_anchors)
  data = @data_pool[data_signature] ||= fox.data(ids: parent.ids, anchors: parent.send(:fox_anchors))
  push_sql = @sql_pool[data_signature] ||= data.to_sql(format: :exec, ids: parent.ids, delete: :none)

  object = FoxFrame.allocate
  object.send(:initialize, parent, search_path, fox, data, push_sql)
  object
end