Sha256: 843c8af880c5508cb4814d2da2f44862af5f26f3aa890d13ae4e6ce961ef4d73

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 Bytes

Contents

module ActsAsStarable #:nodoc:
  module StarScopes

    def for_starer(starer)
      where(starer_id: starer.id, starer_type: parent_class_name(starer))
    end

    def for_starable(starable)
      where(starable_id: starable.id, starable_type: parent_class_name(starable))
    end

    def for_starer_type(starer_type)
      where(starer_type: starer_type)
    end

    def for_starable_type(starable_type)
      where(starable_type: starable_type)
    end

    def recent(from)
      where(["created_at > ?", (from || 2.weeks.ago).to_s(:db)])
    end

    def descending
      order("stars.created_at DESC")
    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/star_scopes.rb
acts_as_starable-0.1.0 lib/acts_as_starable/star_scopes.rb