drapergem/draper

View on GitHub
lib/draper/query_methods/load_strategy.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
90%
module Draper
  module QueryMethods
    module LoadStrategy
      def self.new(name)
        const_get(name.to_s.camelize).new
      end

      class ActiveRecord
        def allowed?(method)
          ::ActiveRecord::Relation::VALUE_METHODS.include? method
        end
      end

      class Mongoid
        def allowed?(method)
          raise NotImplementedError
        end
      end
    end
  end
end