Class: ConcurrentPipeline::Stores::Schema::RecordContext

Inherits:
Object
  • Object
show all
Defined in:
lib/concurrent_pipeline/stores/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_instance) ⇒ RecordContext

Returns a new instance of RecordContext.



10
11
12
13
# File 'lib/concurrent_pipeline/stores/schema.rb', line 10

def initialize(schema_instance)
  @schema_instance = schema_instance
  @table_name = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject



28
29
# File 'lib/concurrent_pipeline/stores/schema.rb', line 28

def method_missing(...)
end

Instance Attribute Details

#schema_instanceObject (readonly)

Returns the value of attribute schema_instance.



8
9
10
# File 'lib/concurrent_pipeline/stores/schema.rb', line 8

def schema_instance
  @schema_instance
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



8
9
10
# File 'lib/concurrent_pipeline/stores/schema.rb', line 8

def table_name
  @table_name
end

Instance Method Details

#respond_to_missing?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/concurrent_pipeline/stores/schema.rb', line 31

def respond_to_missing?(...)
  true
end

#schema(table_name, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/concurrent_pipeline/stores/schema.rb', line 15

def schema(table_name, &block)
  # Store the table name for later use
  @table_name = table_name

  # Prepend schema migrations to front of the line
  # Wrap the block in a create_table call
  migration_block = Proc.new do
    create_table(table_name, &block)
  end

  schema_instance.prepend_migration(table_name, &migration_block)
end