Class: Arel::Transformer::PrefixSchemaName

Inherits:
Object
  • Object
show all
Defined in:
lib/arel/transformer/prefix_schema_name.rb

Constant Summary collapse

PG_CATALOG =
'pg_catalog'.freeze
DEFAULT_SCHEMA_PRIORITY =
['public', PG_CATALOG].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_priority = DEFAULT_SCHEMA_PRIORITY, override_object_mapping = {}) ⇒ PrefixSchemaName

Returns a new instance of PrefixSchemaName.



10
11
12
13
14
15
16
# File 'lib/arel/transformer/prefix_schema_name.rb', line 10

def initialize(
  schema_priority = DEFAULT_SCHEMA_PRIORITY,
  override_object_mapping = {}
)
  @schema_priority = schema_priority
  @object_mapping = database_object_mapping.merge(override_object_mapping)
end

Instance Attribute Details

#object_mappingObject (readonly)

Returns the value of attribute object_mapping.



7
8
9
# File 'lib/arel/transformer/prefix_schema_name.rb', line 7

def object_mapping
  @object_mapping
end

#schema_priorityObject (readonly)

Returns the value of attribute schema_priority.



8
9
10
# File 'lib/arel/transformer/prefix_schema_name.rb', line 8

def schema_priority
  @schema_priority
end

Instance Method Details

#call(arel, next_middleware) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/arel/transformer/prefix_schema_name.rb', line 18

def call(arel, next_middleware)
  tree = Arel.enhance(arel)
  update_arel_tables(tree)
  update_typecasts(tree)
  update_functions(tree)

  next_middleware.call tree
end