Sha256: ff5eb746d14b13f07dac13b10eaa29135e5d03b836ed6d71c5311754635a3b84

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

module Socialization
  module Stores
    module Mixins
      module Follow

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

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

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

      protected
        def call_after_create_hooks(follower, followable)
          self.send(@after_create_hook, follower, followable) if @after_create_hook
          touch_dependents(follower, followable)
        end

        def call_after_destroy_hooks(follower, followable)
          self.send(@after_destroy_hook, follower, followable) if @after_destroy_hook
          touch_dependents(follower, followable)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
socialization-cassandra-0.0.7.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-cassandra-0.0.6.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-cassandra-0.0.5.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-cassandra-0.0.4.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-cassandra-0.0.3.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-cassandra-0.0.2.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-cassandra-0.0.1.pre.alpha lib/socialization/stores/mixins/follow.rb
socialization-1.1.0 lib/socialization/stores/mixins/follow.rb
socialization-1.0.0 lib/socialization/stores/mixins/follow.rb