Sha256: 1b27467bccd40d5e11994a0a75cde6bc70e8990d0c9bc3c92639f90281b79b2b

Contents?: true

Size: 602 Bytes

Versions: 5

Compression:

Stored size: 602 Bytes

Contents

module Yodeler
  class Notification < ActiveRecord::Base
    validates_presence_of :subscription
    validates_presence_of :event
        
    belongs_to :event, class_name: "Yodeler::Event", foreign_key: :yodeler_event_id
    belongs_to :subscription, class_name: "Yodeler::Subscription", foreign_key: :yodeler_subscription_id

    delegate :event_type, to: :event
    delegate :subscriber, to: :subscription

    def message
      I18n.t("yodeler.event_types.#{event_type_key}.message", event.payload)
    end

    protected
      def event_type_key
        event_type.name.to_sym
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yodeler-0.0.6 lib/yodeler/models/notification.rb
yodeler-0.0.5 lib/yodeler/models/notification.rb
yodeler-0.0.4 lib/yodeler/models/notification.rb
yodeler-0.0.3 lib/yodeler/models/notification.rb
yodeler-0.0.1 lib/yodeler/models/notification.rb