Class: ENM::Namespace::Builder Private
- Inherits:
-
Object
- Object
- ENM::Namespace::Builder
- Defined in:
- lib/enm/namespace.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A builder for ENM::Namespace.
Instance Method Summary collapse
-
#default!(name) ⇒ void
Set the default database for the namespace.
-
#from_ron!(ron, version: ENM::RON_VERSION, default: false) ⇒ void
Add a database to the namespace from a RON string.
-
#from_ron_file!(path, version: ENM::RON_VERSION, default: false) ⇒ void
Add a database to the namespace from a RON file.
-
#from_sql!(name, sql, default: false) ⇒ void
Add a database to the namespace from a SQL string.
-
#from_sql_file!(name, path, default: false) ⇒ void
Add a database to the namespace from a SQL string.
-
#initialize ⇒ Builder
constructor
private
A new instance of Builder.
- #to_h ⇒ { Symbol => Object } private
Constructor Details
#initialize ⇒ Builder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Builder.
94 95 96 97 |
# File 'lib/enm/namespace.rb', line 94 def initialize @databases = {} @default = nil end |
Instance Method Details
#default!(name) ⇒ void
This method returns an undefined value.
Set the default database for the namespace.
153 154 155 156 157 |
# File 'lib/enm/namespace.rb', line 153 def default!(name) @default = @databases.fetch(name.to_s) do raise ENM::DatabaseNotFoundError, "Default database #{name} not found in namespace" end end |
#from_ron!(ron, version: ENM::RON_VERSION, default: false) ⇒ void
This method returns an undefined value.
Add a database to the namespace from a RON string.
107 108 109 |
# File 'lib/enm/namespace.rb', line 107 def from_ron!(ron, version: ENM::RON_VERSION, default: false) add!(Database.from_ron(version, ron), default:) end |
#from_ron_file!(path, version: ENM::RON_VERSION, default: false) ⇒ void
This method returns an undefined value.
Add a database to the namespace from a RON file.
119 120 121 |
# File 'lib/enm/namespace.rb', line 119 def from_ron_file!(path, version: ENM::RON_VERSION, default: false) add!(Database.from_ron_file(version, path), default:) end |
#from_sql!(name, sql, default: false) ⇒ void
This method returns an undefined value.
Add a database to the namespace from a SQL string.
131 132 133 |
# File 'lib/enm/namespace.rb', line 131 def from_sql!(name, sql, default: false) add!(Database.from_sql(name, sql), default:) end |
#from_sql_file!(name, path, default: false) ⇒ void
This method returns an undefined value.
Add a database to the namespace from a SQL string.
143 144 145 |
# File 'lib/enm/namespace.rb', line 143 def from_sql_file!(name, path, default: false) add!(Database.from_sql_file(name, path), default:) end |
#to_h ⇒ { Symbol => Object }
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/enm/namespace.rb', line 161 def to_h { databases: @databases, default: @default } end |