Sha256: c8b21044e5bd594cfe5c08232d2b48b4b5e34c140a1e8c7d98e2c38b247d0b8b
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
module ActiveRecord class Base def is_likeable? false end end end module Socialization module Likeable extend ActiveSupport::Concern included do # Specifies if self can be liked. # # @return [Boolean] def is_likeable? true end # Specifies if self is liked by a {Liker} object. # # @return [Boolean] def liked_by?(liker) raise ArgumentError, "#{liker} is not liker!" unless liker.respond_to?(:is_liker?) && liker.is_liker? Socialization.like_model.likes?(liker, self) end # Returns a scope of the {Liker}s likeing self. # # @param [Class] klass the {Liker} class to be included in the scope. e.g. `User`. # @return [Array<Liker, Numeric>] An array of Liker objects or IDs def likers(klass, opts = {}) Socialization.like_model.likers(self, klass, opts) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
socialization-0.5.0.beta | lib/socialization/victims/likeable.rb |