Module: Badgeable::Adapters
- Defined in:
- lib/badgeable/adapters.rb,
lib/badgeable/adapters/mongoid_adapter.rb,
lib/badgeable/adapters/active_record_adapter.rb
Defined Under Namespace
Modules: ActiveRecordAdapter, InstanceMethods, MongoidAdapter
Class Attribute Summary collapse
-
.current_adapter ⇒ Object
Returns the value of attribute current_adapter.
Class Method Summary collapse
Class Attribute Details
.current_adapter ⇒ Object
Returns the value of attribute current_adapter.
5 6 7 |
# File 'lib/badgeable/adapters.rb', line 5 def current_adapter @current_adapter end |
Class Method Details
.connect(klass) ⇒ Object
16 17 18 19 |
# File 'lib/badgeable/adapters.rb', line 16 def self.connect(klass) raise ArgumentError, "Badgeable needs a database adapter to work. Add one of the following to your Gemfile: #{Badgeable::Adapters.supported_adapters.map {|name| 'badgeable_' + name }}" unless Badgeable::Adapters.current_adapter && (Badgeable::Adapters.supported_adapters.include? Badgeable::Adapters.current_adapter) klass.send(:include, "Badgeable::Adapters::#{current_adapter.to_s.camelize}Adapter".constantize) end |
.supported_adapters ⇒ Object
12 13 14 |
# File 'lib/badgeable/adapters.rb', line 12 def self.supported_adapters [:active_record, :mongoid] end |
.use(adapter) ⇒ Object
8 9 10 |
# File 'lib/badgeable/adapters.rb', line 8 def self.use(adapter) @current_adapter = adapter end |