Class: Shamu::Events::ActiveRecord::Message

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/shamu/events/active_record/message.rb

Overview

The model used to store the event messages in the database.

Scope collapse

Instance Attribute Details

#by_channelActiveRecord::Relation

Returns messages posted to the given channel.

Returns:

  • (ActiveRecord::Relation)

    messages posted to the given channel.



36
37
38
# File 'lib/shamu/events/active_record/message.rb', line 36

scope :by_channel, ->( name ) {
  where( channel: name )
}

#sinceActiveRecord::Relation

Returns messages posted after the given created_at.

Returns:

  • (ActiveRecord::Relation)

    messages posted after the given created_at.



42
43
44
# File 'lib/shamu/events/active_record/message.rb', line 42

scope :since, ->( created_at ) {
  where( arel_table[:created_at].gt( created_at ) )
}