Class: Postal::MessageScope

Inherits:
Object
  • Object
show all
Defined in:
lib/postal/message_scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ MessageScope

Returns a new instance of MessageScope.


8
9
10
11
# File 'lib/postal/message_scope.rb', line 8

def initialize(client)
  @client = client
  @includes = []
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client


6
7
8
# File 'lib/postal/message_scope.rb', line 6

def client
  @client
end

Instance Method Details

#expansionsObject

Return the current includes


24
25
26
27
28
29
30
# File 'lib/postal/message_scope.rb', line 24

def expansions
  if @includes.include?(:all)
    true
  else
    @includes.map(&:to_s)
  end
end

#find_by_id(id) ⇒ Object

Find a given message by its ID


35
36
37
# File 'lib/postal/message_scope.rb', line 35

def find_by_id(id)
  Message.find_with_scope(self, id)
end

#includes(*includes) ⇒ Object

Add includes to the scope


16
17
18
19
# File 'lib/postal/message_scope.rb', line 16

def includes(*includes)
  @includes.push(*includes)
  self
end