Class: ActiveStash::Search::OrmAdapter

Inherits:
OrmAdapter::Base
  • Object
show all
Defined in:
lib/orm_adapter/activestash.rb

Instance Method Summary collapse

Instance Method Details

#find_first(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/orm_adapter/activestash.rb', line 5

def find_first(options = {})
	cs_fields, db_fields, _options = discriminate_options(options)

	records = nil

	if db_fields.empty?
		klass.query(cs_fields)
			.first
	else
		if cs_fields.empty?
			OrmAdapter::ActiveRecord.new(klass).find_first(options)
		else
			stash_ids = klass.query(cs_fields).map(&:uuid)
			OrmAdapter::ActiveRecord.new(klass).find_first(db_fields.merge(stash_id: stash_ids))
		end
	end
end

#get(id) ⇒ Object



27
28
29
# File 'lib/orm_adapter/activestash.rb', line 27

def get(id)
	OrmAdapter::ActiveRecord.new(klass).get(id)
end

#get!(id) ⇒ Object



23
24
25
# File 'lib/orm_adapter/activestash.rb', line 23

def get!(id)
	OrmAdapter::ActiveRecord.new(klass).get!(id)
end