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
# File 'lib/fabulator_exhibit_extension/database.rb', line 3

def initialize(db)
  @db = db
end

Instance Method Details

#[](t) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/fabulator_exhibit_extension/database.rb', line 14

def [](t)
  case t.to_sym
    when :items
      return ItemCollection.new(@db)
    when :properties
      return PropertyCollection.new(@db)
    when :types
      return TypeCollection.new(@db)
  end
end

#to_jsonObject



7
8
9
10
11
12
# File 'lib/fabulator_exhibit_extension/database.rb', line 7

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