Sha256: 5d2a39af5f4df284c52f91c506b481037715ae1a4deaa5870da42fef79051325

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

module FollowableBehaviour
  module FollowerLib

    private

    # Retrieves the parent class name if using STI.
    def parent_class_name(obj)
      obj.class.base_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.where(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
followable_behaviour-0.2.0 lib/followable_behaviour/follower_lib.rb
followable_behaviour-0.1.0 lib/followable_behaviour/follower_lib.rb