Class: ConcurrentPipeline::Stores::Schema
- Inherits:
-
Object
- Object
- ConcurrentPipeline::Stores::Schema
show all
- Defined in:
- lib/concurrent_pipeline/stores/schema.rb
Defined Under Namespace
Classes: Migration, Record, RecordContext
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Schema
37
38
39
40
41
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 37
def initialize
@migrations = []
@records = {}
@migration_counter = 1
end
|
Instance Attribute Details
#migrations ⇒ Object
Returns the value of attribute migrations.
36
37
38
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 36
def migrations
@migrations
end
|
#records ⇒ Object
Returns the value of attribute records.
36
37
38
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 36
def records
@records
end
|
Instance Method Details
#dir(path = nil) ⇒ Object
43
44
45
46
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 43
def dir(path = nil)
@dir = path if path
@dir
end
|
#migrate(version = @migration_counter += 1, &block) ⇒ Object
48
49
50
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 48
def migrate(version = @migration_counter += 1, &block)
migrations << Migration.new(version: version, block: block)
end
|
#prepend_migration(version, &block) ⇒ Object
52
53
54
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 52
def prepend_migration(version, &block)
migrations.unshift(Migration.new(version: version, block: block))
end
|
#record(name, table: nil, &block) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/concurrent_pipeline/stores/schema.rb', line 56
def record(name, table: nil, &block)
= table
if block
context = RecordContext.new(self)
context.instance_exec(&block)
||= context.table_name
end
records[name] = Record.new(
name: name,
table: ,
block: block
)
end
|