Class: Libertree::Model::NodeSubscription

Inherits:
Object
  • Object
show all
Defined in:
lib/libertree/model/node_subscription.rb

Constant Summary collapse

STATES =
[ :none,
:pending,
:unconfigured,
:subscribed ]

Class Method Summary collapse

Class Method Details

.for(jid_or_host) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/libertree/model/node_subscription.rb', line 12

def self.for(jid_or_host)
  return self  unless jid_or_host
  jid_or_host = jid_or_host.to_s
  if jid_or_host.include?('@')
    self.where(jid: jid_or_host)
  else
    host_pattern = self.where(Sequel.lit('true')).escape_like(jid_or_host.to_s)
    self.where(Sequel.like(:jid, "%@#{host_pattern}"))
  end
end