Sha256: c23025a3cd59f6e4eacfc141df64ab832f5c1ed3403aa15e9e8749272fa68f82

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

module Socialization
  module Stores
    module Mixins
      module Like

      public
        def touch(what = nil)
          if what.nil?
            @touch || false
          else
            raise Socialization::ArgumentError unless [:all, :liker, :likeable, false, nil].include?(what)
            @touch = what
          end
        end

        def after_like(method)
          raise Socialization::ArgumentError unless method.is_a?(Symbol) || method.nil?
          @after_create_hook = method
        end

        def after_unlike(method)
          raise Socialization::ArgumentError unless method.is_a?(Symbol) || method.nil?
          @after_destroy_hook = method
        end

      protected
        def call_after_create_hooks(liker, likeable)
          self.send(@after_create_hook, liker, likeable) if @after_create_hook
          touch_dependents(liker, likeable)
        end

        def call_after_destroy_hooks(liker, likeable)
          self.send(@after_destroy_hook, liker, likeable) if @after_destroy_hook
          touch_dependents(liker, likeable)
        end

      end
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
socialization-2.0.2 lib/socialization/stores/mixins/like.rb
socialization-2.0.1 lib/socialization/stores/mixins/like.rb
socialization-2.0.0 lib/socialization/stores/mixins/like.rb
socialization-1.2.3 lib/socialization/stores/mixins/like.rb
socialization-1.2.2 lib/socialization/stores/mixins/like.rb
socialization-1.2.1 lib/socialization/stores/mixins/like.rb
twrk-socialization-1.2.0 lib/socialization/stores/mixins/like.rb
twrk-socialization-0.0.1 lib/socialization/stores/mixins/like.rb
socialization-1.2.0 lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.7.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.6.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.5.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.4.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.3.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.2.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-cassandra-0.0.1.pre.alpha lib/socialization/stores/mixins/like.rb
socialization-1.1.0 lib/socialization/stores/mixins/like.rb
socialization-1.0.0 lib/socialization/stores/mixins/like.rb