Sha256: be3567d7e65cd7a43e9aefa51ff06b8b6822cd034385d8ebc6e74fad790efc9f

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

module Bullet
  module Notification
    class Base
      attr_accessor :presenter
      attr_reader :base_class, :associations, :path

      def initialize( base_class, associations, path = nil )
        @base_class = base_class
        @associations = associations.is_a?( Array ) ? associations : [ associations ]
        @path = path
      end

      def title
      end

      def body
      end
      
      def body_with_caller
        body
      end
      
      def standard_notice
        @standard_notifice ||= title + "\n" + body
      end

      def full_notice
        @full_notice ||= title + "\n" + body_with_caller
      end

      def present_inline
        return unless self.presenter.respond_to? :inline
        self.presenter.send( :inline, self ) 
      end

      def present_out_of_channel
        return unless self.presenter.respond_to? :out_of_channel
        self.presenter.send( :out_of_channel, self )
      end

      def eql?( other )
        klazz_associations_str == other.klazz_associations_str
      end

      def hash
        klazz_associations_str.hash
      end

      protected
      def klazz_associations_str
        "  #{@base_class} => [#{@associations.map(&:inspect).join(', ')}]"
      end

      def associations_str
        ":include => #{@associations.map{|a| a.to_s.to_sym unless a.is_a? Hash}.inspect}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bullet-2.0.0.rc2 lib/bullet/notification/base.rb
bullet-2.0.0.rc1 lib/bullet/notification/base.rb
bullet-2.0.0.beta.4 lib/bullet/notification/base.rb
bullet-2.0.0.beta.3 lib/bullet/notification/base.rb