Class: Bluff::Support::Persistence::Base
- Inherits:
-
Object
- Object
- Bluff::Support::Persistence::Base
- Defined in:
- lib/bluff/support/persistence/base.rb
Constant Summary collapse
- @@adapters =
[]
Class Method Summary collapse
Class Method Details
.persist(record, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bluff/support/persistence/base.rb', line 12 def persist(record, = {}) adapters = @@adapters.select {|adapter| adapter.persists?(record)} if adapters.empty? raise "#{[:as] || record.class} is not persistable (#{record})" else # should first try to persist new associations adapters.first.persist(record) end end |
.register(adapter) ⇒ Object
8 9 10 |
# File 'lib/bluff/support/persistence/base.rb', line 8 def register(adapter) @@adapters << adapter end |