Module: RPlatform::Rails::ModelExtensions::ActsAsFacebookUser::InstanceMethods
- Defined in:
- lib/rplatform_rails/model_extensions.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#facebook_session(network = 'facebook') ⇒ Object
TODO: to help developers stay within the TOS, we should have a method in here like “with_facebook_scope(fbsession)…”.
- #facebook_session=(sess) ⇒ Object
- #has_infinite_session_key? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
:nodoc:
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/rplatform_rails/model_extensions.rb', line 189 def self.included(base) # :nodoc: ActsAsFacebookUser::ACTORS << base ActsAsFacebookUser::FIELDS.each do |fieldname| # TODO: do getInfo caching base.class_eval <<-EOF def #{fieldname} if facebook_session.ready? return facebook_session.users_getInfo( :uids => [facebook_uid], :fields => ActsAsFacebookUser::FIELDS).user.send(:#{fieldname}) else return nil end end EOF end end |
Instance Method Details
#facebook_session(network = 'facebook') ⇒ Object
TODO: to help developers stay within the TOS, we should have a method in here like “with_facebook_scope(fbsession)…”
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/rplatform_rails/model_extensions.rb', line 166 def facebook_session(network='facebook') if !@facebook_session @facebook_session = FacebookWebSession.new(self.facebook_api_key(network), self.facebook_api_secret(network)) begin @facebook_session.activate_with_previous_session(self.facebook_session_key, self.facebook_uid) rescue # not a valid facebook session, should we nil it out? end end return @facebook_session end |
#facebook_session=(sess) ⇒ Object
178 179 180 181 182 |
# File 'lib/rplatform_rails/model_extensions.rb', line 178 def facebook_session=(sess) @facebook_session = sess self.facebook_session_key = @facebook_session.session_key self.facebook_uid = @facebook_session.session_user_id end |
#has_infinite_session_key? ⇒ Boolean
184 185 186 187 |
# File 'lib/rplatform_rails/model_extensions.rb', line 184 def has_infinite_session_key? # TODO: this check should really look at expires return self.facebook_session_key != nil end |