Sha256: 8efaa4483c47a16318e711876c46e82bf22d82cb1da2d2c88bafba3dccf01ebb

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module Socialization
  module Stores
    module Mixins
      module Follow

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

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

        def after_unfollow(method)
          raise 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

2 entries across 2 versions & 1 rubygems

Version Path
socialization-0.5.0.beta4 lib/socialization/stores/mixins/follow.rb
socialization-0.5.0.beta3 lib/socialization/stores/mixins/follow.rb