Class: Honeycomb::Database::Interact
- Inherits:
-
Object
- Object
- Honeycomb::Database::Interact
- Defined in:
- lib/honeycomb/database/interact.rb
Instance Method Summary collapse
-
#all(&block) ⇒ Object
Used for executing a query against all databases at once.
-
#individual(repo, &block) ⇒ Object
Used for executing a query against a single database.
Instance Method Details
#all(&block) ⇒ Object
Used for executing a query against all databases at once.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/honeycomb/database/interact.rb', line 26 def all(&block) all_values = [] ::DataMapper::Repository.adapters.each do |repo| if repo[0] == :default next end begin response = DataMapper.repository(repo[0]) {yield} if response.kind_of?(DataMapper::Collection) response.each do |x| all_values << x end else all_values << response if response end rescue Exception => e #puts e.message end end all_values end |
#individual(repo, &block) ⇒ Object
Used for executing a query against a single database.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/honeycomb/database/interact.rb', line 49 def individual(repo, &block) all_values = [] begin response = DataMapper.repository(repo[0]) {yield} if response.kind_of?(DataMapper::Collection) response.each do |x| all_values << x end else all_values << response if response end rescue Exception => e #puts e.message end all_values end |