class MarkLogic::Forest
Attributes
forest_name[RW]
Public Class Methods
load(forest_name, host_name = nil, conn = nil)
click to toggle source
# File lib/marklogic/forest.rb, line 16 def self.load(forest_name, host_name = nil, conn = nil) db = Forest.new(forest_name, host_name, conn) db.load db end
new(forest_name, host_name = nil, conn = nil)
click to toggle source
# File lib/marklogic/forest.rb, line 6 def initialize(forest_name, host_name = nil, conn = nil) self.connection = conn @forest_name = forest_name @host_name = host_name || self.manage_connection.host @options = { "forest-name" => @forest_name, "host" => @host_name } end
Public Instance Methods
[](key)
click to toggle source
# File lib/marklogic/forest.rb, line 36 def [](key) @options[key] end
[]=(key, value)
click to toggle source
# File lib/marklogic/forest.rb, line 32 def []=(key, value) @options[key] = value end
create()
click to toggle source
# File lib/marklogic/forest.rb, line 49 def create r = manage_connection.post_json( %Q{/manage/v2/forests?format=json}, @options) end
database=(db)
click to toggle source
# File lib/marklogic/forest.rb, line 44 def database=(db) @database = db @options['database'] = db.database_name end
drop()
click to toggle source
# File lib/marklogic/forest.rb, line 59 def drop r = manage_connection.delete(%Q{/manage/v2/forests/#{forest_name}?level=full&format=json}) end
exists?()
click to toggle source
# File lib/marklogic/forest.rb, line 55 def exists? manage_connection.head(%Q{/manage/v2/forests/#{forest_name}}).code.to_i == 200 end
has_key?(key)
click to toggle source
# File lib/marklogic/forest.rb, line 40 def has_key?(key) @options.has_key?(key) end
load()
click to toggle source
# File lib/marklogic/forest.rb, line 22 def load resp = manage_connection.get(%Q{/manage/v2/forests/#{forest_name}/properties?format=json}) if resp.code.to_i == 200 options = Oj.load(resp.body) options.each do |key, value| self[key] = value end end end