Module: Tire::Model::Import::Strategy
- Defined in:
- lib/tire/model/import.rb
Overview
Importing strategies for common persistence frameworks (ActiveModel, Mongoid), as well as pagination libraries (WillPaginate, Kaminari), or a custom strategy.
Defined Under Namespace
Modules: Base Classes: ActiveRecord, Default, Kaminari, Mongoid, WillPaginate
Class Method Summary collapse
Class Method Details
.from_class(klass, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tire/model/import.rb', line 30 def self.from_class(klass, ={}) return const_get([:strategy]).new(klass, ) if [:strategy] case when defined?(::ActiveRecord) && klass.ancestors.include?(::ActiveRecord::Base) ActiveRecord.new klass, when defined?(::Mongoid::Document) && klass.ancestors.include?(::Mongoid::Document) Mongoid.new klass, when defined?(Kaminari) && klass.respond_to?(:page) Kaminari.new klass, when defined?(WillPaginate) && klass.respond_to?(:paginate) WillPaginate.new klass, else Default.new klass, end end |