Class: Invity::Facebook::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/invity/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Message

Returns a new instance of Message.



6
7
8
9
10
# File 'lib/invity/message.rb', line 6

def initialize(options = {})
  [:sender, :recievers, :subject, :body, :access_token].each { |w|
    send("#{w}=", options[w])
  }
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



4
5
6
# File 'lib/invity/message.rb', line 4

def access_token
  @access_token
end

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/invity/message.rb', line 4

def body
  @body
end

#recieverObject

Returns the value of attribute reciever.



4
5
6
# File 'lib/invity/message.rb', line 4

def reciever
  @reciever
end

#recieversObject

Returns the value of attribute recievers.



4
5
6
# File 'lib/invity/message.rb', line 4

def recievers
  @recievers
end

#senderObject

Returns the value of attribute sender.



4
5
6
# File 'lib/invity/message.rb', line 4

def sender
  @sender
end

#subjectObject

Returns the value of attribute subject.



4
5
6
# File 'lib/invity/message.rb', line 4

def subject
  @subject
end

Instance Method Details

#deliver(opt = nil) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/invity/message.rb', line 16

def deliver(opt = nil)
  case opt
    when :all         then deliver_all
    when :all_delayed then deliver_all_as_delayed
    when :delayed     then deliver_as_delayed
    else; deliver_each
  end
end

#deliver_allObject



25
26
27
28
29
# File 'lib/invity/message.rb', line 25

def deliver_all
  friends.each { |f|
    self.reciever = f; chat
  }
end

#deliver_all_as_delayedObject



31
32
33
34
35
36
# File 'lib/invity/message.rb', line 31

def deliver_all_as_delayed
  friends.each { |f|
    self.reciever = f
    Delayed::Job.enqueue self
  }
end

#deliver_as_delayedObject



38
39
40
41
42
43
# File 'lib/invity/message.rb', line 38

def deliver_as_delayed
  recievers.each { |f|
    self.reciever = f
    Delayed::Job.enqueue self
  }
end

#deliver_eachObject



45
46
47
48
49
# File 'lib/invity/message.rb', line 45

def deliver_each
  recievers.each { |f|
    self.reciever = f; chat
  }
end

#performObject

SPECIAL METHOD USED BY DELAYED-JOBS



12
13
14
# File 'lib/invity/message.rb', line 12

def perform # SPECIAL METHOD USED BY DELAYED-JOBS
  chat
end