Sha256: 92deb1ae6acd0d71e932110424d39baaf5c05318ec4794a0b94fe9421156e347

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

module Socialization
  module Stores
    module Mixins
      module Mention

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

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

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

      protected
        def call_after_create_hooks(mentioner, mentionable)
          self.send(@after_create_hook, mentioner, mentionable) if @after_create_hook
          touch_dependents(mentioner, mentionable)
        end

        def call_after_destroy_hooks(mentioner, mentionable)
          self.send(@after_destroy_hook, mentioner, mentionable) if @after_destroy_hook
          touch_dependents(mentioner, mentionable)
        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/mention.rb
socialization-0.5.0.beta3 lib/socialization/stores/mixins/mention.rb