Sha256: 21c3028244a2b948fee3d4ece2d08f89fcec90f825d0b7be8f39f7d249b975ee

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

module ActsAsFollower
  module FollowerLib

    private

    # Retrieves the parent class name if using STI.
    def parent_class_name(obj)
      if obj.class.superclass != ActiveRecord::Base
        return obj.class.superclass.name
      end
      return obj.class.name
    end

    def apply_options_to_scope(scope, options = {})
      if options.has_key?(:limit)
        scope = scope.limit(options[:limit])
      end
      if options.has_key?(:includes)
        scope = scope.includes(options[:includes])
      end
      if options.has_key?(:joins)
        scope = scope.joins(options[:joins])
      end
      if options.has_key?(:where)
        scope = scope.order(options[:where])
      end
      if options.has_key?(:order)
        scope = scope.order(options[:order])
      end
      scope
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_follower-0.2.1 lib/acts_as_follower/follower_lib.rb
acts_as_follower-0.2.0 lib/acts_as_follower/follower_lib.rb