Class: FabulatorExhibitExtension::Database
- Inherits:
-
Object
- Object
- FabulatorExhibitExtension::Database
- Defined in:
- lib/fabulator_exhibit_extension/database.rb
Instance Method Summary collapse
- #[](t) ⇒ Object
-
#initialize(db) ⇒ Database
constructor
A new instance of Database.
- #to_json ⇒ Object
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_json ⇒ Object
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 |