Class: ActiveGroonga::Database
- Inherits:
-
Object
- Object
- ActiveGroonga::Database
- Defined in:
- lib/active_groonga/database.rb
Instance Method Summary collapse
- #close ⇒ Object
- #ensure_available ⇒ Object
-
#initialize(path) ⇒ Database
constructor
A new instance of Database.
- #remove ⇒ Object
- #reopen ⇒ Object
Constructor Details
#initialize(path) ⇒ Database
Returns a new instance of Database.
20 21 22 23 |
# File 'lib/active_groonga/database.rb', line 20 def initialize(path) @path = path @database = nil end |
Instance Method Details
#close ⇒ Object
44 45 46 47 48 |
# File 'lib/active_groonga/database.rb', line 44 def close return if @database.nil? @database.close @database = nil end |
#ensure_available ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_groonga/database.rb', line 25 def ensure_available return if @database if @path.exist? @database = Groonga::Database.open(@path.to_s, :context => Base.context) else FileUtils.mkdir_p(@path.dirname) unless @path.dirname.exist? @database = Groonga::Database.create(:path => @path.to_s, :context => Base.context) end end |
#remove ⇒ Object
37 38 39 40 41 42 |
# File 'lib/active_groonga/database.rb', line 37 def remove ensure_available if @path.exist? return if @database.nil? @database.remove @database = nil end |
#reopen ⇒ Object
50 51 52 53 |
# File 'lib/active_groonga/database.rb', line 50 def reopen close ensure_available end |