Class: FabulatorExhibitExtension::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/fabulator_exhibit_extension/database.rb

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ Database

Returns a new instance of Database.



3
4
5
6
7
8
9
10
# File 'lib/fabulator_exhibit_extension/database.rb', line 3

def initialize(db)
  @db = db
  @info = {
    :items => ItemCollection.new(@db),
    :properties => PropertyCollection.new(@db),
    :types => TypeCollection.new(@db)
  }
end

Instance Method Details

#[](t) ⇒ Object



19
20
21
# File 'lib/fabulator_exhibit_extension/database.rb', line 19

def [](t)
  @info[t.to_sym]
end

#to_jsonObject



12
13
14
15
16
17
# File 'lib/fabulator_exhibit_extension/database.rb', line 12

def to_json
  '{ "items":' + @info[:items].to_json + ', ' +
  '  "types":' + @info[:types].to_json + ', ' +
  '  "properties":' + @info[:properties].to_json +
  '}'
end