Class: UnifiedDB::Backend::Base
- Inherits:
-
Object
- Object
- UnifiedDB::Backend::Base
- Defined in:
- lib/unified_db/backend/base.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #find(params) ⇒ Object
- #find_by_id(id) ⇒ Object
- #find_by_title(title) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #result ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/unified_db/backend/base.rb', line 11 def initialize @result = [] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/unified_db/backend/base.rb', line 5 def id @id end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/unified_db/backend/base.rb', line 5 def title @title end |
Class Method Details
.find(params) ⇒ Object
7 8 9 |
# File 'lib/unified_db/backend/base.rb', line 7 def self.find(params) new.find(params) end |
Instance Method Details
#find(params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/unified_db/backend/base.rb', line 15 def find(params) if params[:id] find_by_id params[:id] elsif params[:t] || params[:title] find_by_title(params[:t] || params[:title]) else raise ApiError, 'no search criteria specified' end result rescue ApiError => e { :status => 'error', :reason => e. } end |
#find_by_id(id) ⇒ Object
32 33 34 |
# File 'lib/unified_db/backend/base.rb', line 32 def find_by_id(id) raise ApiError, 'not implemented' end |
#find_by_title(title) ⇒ Object
36 37 38 |
# File 'lib/unified_db/backend/base.rb', line 36 def find_by_title(title) raise ApiError, 'not implemented' end |
#result ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/unified_db/backend/base.rb', line 40 def result { :status => 'success', :service => service, :result => @result } end |