Class: Postspec::Frame
- Inherits:
-
Object
- Object
- Postspec::Frame
- Defined in:
- lib/postspec/frame.rb
Overview
TODO: Add #stack and forward #postspec to it
Direct Known Subclasses
Instance Attribute Summary collapse
-
#anchors ⇒ Object
readonly
Returns the value of attribute anchors.
-
#ids ⇒ Object
readonly
Returns the value of attribute ids.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#pop_sql ⇒ Object
readonly
Returns the value of attribute pop_sql.
-
#postspec ⇒ Object
readonly
Returns the value of attribute postspec.
-
#push_sql ⇒ Object
readonly
Returns the value of attribute push_sql.
-
#search_path ⇒ Object
readonly
Returns the value of attribute search_path.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(postspec, parent, search_path, push_sql, pop_sql, ids, fox_anchors) ⇒ Frame
constructor
A new instance of Frame.
- #schema ⇒ Object
-
#transaction? ⇒ Boolean
Returns true if this frame is associated with a transaction.
Constructor Details
#initialize(postspec, parent, search_path, push_sql, pop_sql, ids, fox_anchors) ⇒ Frame
Returns a new instance of Frame.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/postspec/frame.rb', line 39 def initialize(postspec, parent, search_path, push_sql, pop_sql, ids, fox_anchors) constrain postspec, Postspec constrain parent, NilClass, Frame constrain search_path, [String], NilClass constrain push_sql, String, [String], NilClass constrain pop_sql, String, [String], NilClass constrain ids, { String => Integer } constrain fox_anchors, FixtureFox::Anchors, NilClass @postspec = postspec @parent = parent @search_path = search_path || %w(public) @push_sql = ["set search_path to #{@search_path.join(", ")}"] + Array(push_sql || []) @pop_sql = Array(pop_sql || []) + (parent ? ["set search_path to #{parent.search_path.join(", ")}"] : []) @ids = ids || {} @fox_anchors = fox_anchors || FixtureFox::Anchors.new(@postspec.type) anchors = @fox_anchors.values.map { |anchor| [anchor.name, anchor.id] }.to_h @anchors = (parent ? parent.anchors.merge(anchors) : anchors) end |
Instance Attribute Details
#anchors ⇒ Object (readonly)
Returns the value of attribute anchors.
37 38 39 |
# File 'lib/postspec/frame.rb', line 37 def anchors @anchors end |
#ids ⇒ Object (readonly)
Returns the value of attribute ids.
36 37 38 |
# File 'lib/postspec/frame.rb', line 36 def ids @ids end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
30 31 32 |
# File 'lib/postspec/frame.rb', line 30 def parent @parent end |
#pop_sql ⇒ Object (readonly)
Returns the value of attribute pop_sql.
35 36 37 |
# File 'lib/postspec/frame.rb', line 35 def pop_sql @pop_sql end |
#postspec ⇒ Object (readonly)
Returns the value of attribute postspec.
29 30 31 |
# File 'lib/postspec/frame.rb', line 29 def postspec @postspec end |
#push_sql ⇒ Object (readonly)
Returns the value of attribute push_sql.
34 35 36 |
# File 'lib/postspec/frame.rb', line 34 def push_sql @push_sql end |
#search_path ⇒ Object (readonly)
Returns the value of attribute search_path.
31 32 33 |
# File 'lib/postspec/frame.rb', line 31 def search_path @search_path end |
Instance Method Details
#dump ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/postspec/frame.rb', line 61 def dump() puts self.class indent { puts "search_path: #{search_path}" puts "push_sql:" indent { puts push_sql } puts "pop:sql:" indent { puts pop_sql } } end |
#schema ⇒ Object
32 |
# File 'lib/postspec/frame.rb', line 32 def schema() @search_path.first end |
#transaction? ⇒ Boolean
Returns true if this frame is associated with a transaction
59 |
# File 'lib/postspec/frame.rb', line 59 def transaction?() true end |