Sha256: 8322a7cb06d05c5ac041912863cd68a2e386180d99cf40ed6a8dd734eceb281b

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

module ActsAsStarable
  module StarerLib

    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.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
acts_as_starable-0.1.1 lib/acts_as_starable/starer_lib.rb
acts_as_starable-0.1.0 lib/acts_as_starable/starer_lib.rb