Sha256: 3808ec1d27ad63cb22b3dad1241e444af44e5eaac20316e7b1bf16fed7c09efc

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

module Shamu
  module Events
    module ActiveRecord

      # The model used to store the event messages in the database.
      class Message < ::ActiveRecord::Base

        self.table_name = "shamu_event_messages"
        self.primary_key = "id"

        # ============================================================================
        # @!group Attributes
        #

        # @!attribute
        # @return [String] id of the message a UUID.

        # @!attribute
        # @return [Integer] channel_id

        # @!attribute
        # @return [String] message the serialized message.

        # @!attribute
        # @return [DateTime] timestamp when the event was submitted.

        #
        # @!endgroup Attributes

        # ============================================================================
        # @!group Scope
        #

        # @!attribute
        # @return [ActiveRecord::Relation] messages posted to the given channel.
        scope :by_channel, ->( name ) {
          where( channel: name )
        }

        # @!attribute
        # @return [ActiveRecord::Relation] messages posted after the given created_at.
        scope :since, ->( created_at ) {
          where( arel_table[:created_at].gt( created_at ) )
        }

        #
        # @!endgroup Scope

      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shamu-0.0.24 lib/shamu/events/active_record/message.rb
shamu-0.0.21 lib/shamu/events/active_record/message.rb
shamu-0.0.20 lib/shamu/events/active_record/message.rb
shamu-0.0.19 lib/shamu/events/active_record/message.rb
shamu-0.0.18 lib/shamu/events/active_record/message.rb
shamu-0.0.17 lib/shamu/events/active_record/message.rb
shamu-0.0.15 lib/shamu/events/active_record/message.rb
shamu-0.0.14 lib/shamu/events/active_record/message.rb
shamu-0.0.13 lib/shamu/events/active_record/message.rb
shamu-0.0.11 lib/shamu/events/active_record/message.rb
shamu-0.0.9 lib/shamu/events/active_record/message.rb
shamu-0.0.8 lib/shamu/events/active_record/message.rb
shamu-0.0.7 lib/shamu/events/active_record/message.rb
shamu-0.0.5 lib/shamu/events/active_record/message.rb
shamu-0.0.4 lib/shamu/events/active_record/message.rb
shamu-0.0.3 lib/shamu/events/active_record/message.rb
shamu-0.0.2 lib/shamu/events/active_record/message.rb