Skip to content

Commit

Permalink
Added optional schema to collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Naiman committed Sep 20, 2016
1 parent e3e5384 commit c6eebe0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/rasti/db/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def many_to_many(name, options={})

end

def initialize(db)
def initialize(db, schema=nil)
@db = db
@schema = schema
end

def insert(attributes)
Expand Down Expand Up @@ -98,10 +99,10 @@ def query(&block)

private

attr_reader :db
attr_reader :db, :schema

def dataset
db[self.class.collection_name]
db[schema.nil? ? self.class.collection_name : "#{schema}__#{self.class.collection_name}".to_sym]
end

end
Expand Down

0 comments on commit c6eebe0

Please sign in to comment.