Class: Messaging::Adapters::Postgres::Category
- Inherits:
-
Object
- Object
- Messaging::Adapters::Postgres::Category
- Defined in:
- lib/messaging/adapters/postgres/category.rb
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the category.
Instance Method Summary collapse
- #delete_messages_older_than!(time) ⇒ Object
-
#initialize(name) ⇒ Category
constructor
private
Should not be used directly.
- #inspect ⇒ Object
-
#messages ⇒ ActiveRecord::Relation
Access to all messages in the category sorted by created_at.
- #messages_older_than(time) ⇒ Object
Constructor Details
#initialize(name) ⇒ Category
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Should not be used directly. Use Messaging.category or Store#category
13 14 15 |
# File 'lib/messaging/adapters/postgres/category.rb', line 13 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the category.
6 7 8 |
# File 'lib/messaging/adapters/postgres/category.rb', line 6 def name @name end |
Instance Method Details
#delete_messages_older_than!(time) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/messaging/adapters/postgres/category.rb', line 27 def (time) SerializedMessage.transaction do ActiveRecord::Base.connection.execute "SET LOCAL statement_timeout = '0'" (time).delete_all end end |
#inspect ⇒ Object
34 35 36 |
# File 'lib/messaging/adapters/postgres/category.rb', line 34 def inspect "#<Category:#{name}>>" end |
#messages ⇒ ActiveRecord::Relation
Access to all messages in the category sorted by created_at
19 20 21 |
# File 'lib/messaging/adapters/postgres/category.rb', line 19 def SerializedMessage.where(stream_category: name).order(:created_at) end |
#messages_older_than(time) ⇒ Object
23 24 25 |
# File 'lib/messaging/adapters/postgres/category.rb', line 23 def (time) .where('created_at < ?', time) end |