Module: Sequel::SearchPath
- Defined in:
- lib/sequel/extensions/search_path.rb,
lib/sequel/extensions/search_path/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Method Summary collapse
-
#active_schema ⇒ Object
The schema that new objects will be created in.
- #override_schema(*new_schemas, &block) ⇒ Object
- #schemas ⇒ Object
- #schemas=(schemas) ⇒ Object
- #search_path ⇒ Object (also: #show_search_path)
- #use_schema(*new_schemas, &block) ⇒ Object
Instance Method Details
#active_schema ⇒ Object
The schema that new objects will be created in.
35 36 37 |
# File 'lib/sequel/extensions/search_path.rb', line 35 def active_schema schemas.first end |
#override_schema(*new_schemas, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sequel/extensions/search_path.rb', line 11 def override_schema(*new_schemas, &block) synchronize do previous_schemas = schemas begin self.schemas = new_schemas yield ensure self.schemas = previous_schemas end end end |
#schemas ⇒ Object
24 25 26 |
# File 'lib/sequel/extensions/search_path.rb', line 24 def schemas Thread.current[schemas_key] ||= [:public] end |
#schemas=(schemas) ⇒ Object
28 29 30 31 32 |
# File 'lib/sequel/extensions/search_path.rb', line 28 def schemas=(schemas) schemas = schemas.map(&:to_sym).uniq Thread.current[schemas_key] = schemas set_search_path(schemas) end |
#search_path ⇒ Object Also known as: show_search_path
39 40 41 |
# File 'lib/sequel/extensions/search_path.rb', line 39 def search_path self["SHOW search_path"].get end |
#use_schema(*new_schemas, &block) ⇒ Object
7 8 9 |
# File 'lib/sequel/extensions/search_path.rb', line 7 def use_schema(*new_schemas, &block) synchronize { override_schema(*(new_schemas + schemas), &block) } end |