cirandas.net

ref: master

plugins/fb_app/lib/ext/profile.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require_dependency 'profile'
# hate to wrte this, but without Noosfero::Plugin::Settings is loaded instead
require 'fb_app_plugin/settings'

# attr_accessible must be defined on subclasses
Profile.descendants.each do |subclass|
  subclass.class_eval do
    attr_accessible :fb_app_settings
  end
end

class Profile

  def fb_app_settings attrs = {}
    @fb_app_settings ||= FbAppPlugin::Settings.new self, attrs
    attrs.each{ |a, v| @fb_app_settings.send "#{a}=", v }
    @fb_app_settings
  end
  alias_method :fb_app_settings=, :fb_app_settings

  has_many :fb_app_page_tabs, class_name: 'FbAppPlugin::PageTab'

  def fb_app_auth
    provider = FbAppPlugin.oauth_provider_for self.environment
    self.oauth_auths.where(provider_id: provider.id).first
  end

end