Guest User

Untitled

a guest
Jul 31st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. require 'rubygems'
  2. require 'ohm'
  3.  
  4. class Change < Ohm::Model
  5. attribute :description
  6. attribute :statement
  7. attribute :apply_at
  8. attribute :created_at
  9. reference :creator, Person
  10. set :databases, Database
  11.  
  12. index :creator_id
  13. end
  14.  
  15. class Person < Ohm::Model
  16. attribute :name
  17. attribute :password
  18. attribute :created_at
  19. collection :changes, Change
  20. end
  21.  
  22. class Database < Ohm::Model
  23. attribute :name
  24. attribute :hostname
  25. attribute :user
  26. attribute :password
  27. attribute :schema
  28. end
  29.  
  30. >> c = Change[1]
  31. => #<Change:1 description="Test DB Query" statement="SHOW DATABASES" apply_at="Wed May 19 18:07:04 -0400 2010" created_at="Wed May 19 18:07:09 -0400 2010" creator_id="1" databases=#<Set (Database): [#<Database:1 name="QADB - iQA" hostname="qadb.ove.local" user="dbchanges" password="1audit1" schema="ove_production">]>>
  32. >> p = Person[1]
  33. => #<Person:1 name="Mark" password="password" created_at="Wed May 19 18:04:48 -0400 2010">
  34. >> d = Database[1]
  35. => #<Database:1 name="QADB - iQA" hostname="qadb.ove.local" user="dbchanges" password="1audit1" schema="ove_production">
  36. >> c.creator
  37. => #<Person:1 name="Mark" password="password" created_at="Wed May 19 18:04:48 -0400 2010">
  38. >> p.changes
  39. Ohm::Model::IndexNotFound: Ohm::Model::IndexNotFound
  40. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:817:in `index_key_for'
  41. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:241:in `keys'
  42. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `each'
  43. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `keys'
  44. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `each'
  45. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `keys'
  46. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `tap'
  47. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `keys'
  48. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:275:in `apply'
  49. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:215:in `find'
  50. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:555:in `find'
  51. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:489:in `changes'
  52. from (irb):5
  53. >> c
  54. => #<Change:1 description="Test DB Query" statement="SHOW DATABASES" apply_at="Wed May 19 18:07:04 -0400 2010" created_at="Wed May 19 18:07:09 -0400 2010" creator_id="1" databases=#<Set (Database): [#<Database:1 name="QADB - iQA" hostname="qadb.ove.local" user="dbchanges" password="1audit1" schema="ove_production">]>>
  55. >> c.creator
  56. => #<Person:1 name="Mark" password="password" created_at="Wed May 19 18:04:48 -0400 2010">
  57. >> c.creator.changes
  58. Ohm::Model::IndexNotFound: Ohm::Model::IndexNotFound
  59. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:817:in `index_key_for'
  60. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:241:in `keys'
  61. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `each'
  62. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:240:in `keys'
  63. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `each'
  64. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:238:in `keys'
  65. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `tap'
  66. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:237:in `keys'
  67. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:275:in `apply'
  68. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:215:in `find'
  69. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:555:in `find'
  70. from /Library/Ruby/Gems/1.8/gems/ohm-0.0.35/lib/ohm.rb:489:in `changes'
  71. from (irb):8
  72. >>
Add Comment
Please, Sign In to add comment