Class: Courier::Service::Facebook
- Defined in:
- lib/courier/service/facebook.rb
Instance Method Summary collapse
- #check_args(owner, template, args) ⇒ Object
- #deliver! ⇒ Object
-
#initialize ⇒ Facebook
constructor
A new instance of Facebook.
Methods inherited from Base
config, configure, inherited, #message, #name
Constructor Details
#initialize ⇒ Facebook
Returns a new instance of Facebook.
4 5 6 7 |
# File 'lib/courier/service/facebook.rb', line 4 def initialize raise "No Koala defined. Add gem 'koala' to your Gemfile. " unless defined? Koala super end |
Instance Method Details
#check_args(owner, template, args) ⇒ Object
9 10 11 12 13 |
# File 'lib/courier/service/facebook.rb', line 9 def check_args owner, template, args args[:to]|='me' args[:attachment]||={} super end |
#deliver! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/courier/service/facebook.rb', line 15 def deliver! cache={} .fresh.each do || .owner.respond_to?(:facebook_token) or raise "method facebook_token is not defined in your owner's model #{owner.class}" token = .owner.facebook_token or raise "owner's facebook_token is empty" graph = cache[token] ||= Koala::Facebook::GraphAPI.new(token) graph.put_wall_post(.[:text], .[:attachment], .[:to]) and .set_delivered end end |