Sha256: af241eacc6b975d5ac13ad34f0e4c773287061de50ede1a39fae9bff677d2b1d

Contents?: true

Size: 1.33 KB

Versions: 35

Compression:

Stored size: 1.33 KB

Contents

require 'facebooker/model'
module Facebooker
  class Group
    ##
    # The model of a user's relationship to a group.  Users can occupy different positions within a group (e.g. 'owner')
    class Membership
      include Model
      attr_accessor :position, :gid, :uid
    end
    include Model
    attr_accessor :pic, :pic_small, :pic_big, :name, :creator, :recent_news, :update_time, :group_subtype, :group_type, :website, :office, :description, :venue, :nid

    id_is :gid

    ##
    # Get the full list of members as populated User objects.  First time fetches group members via Facebook API call.  
    # Subsequent calls return cached values.
    # This is a convenience method for getting all of the Membership instances and instantiating User instances for each Membership.
    def members
      @members ||= memberships.map do |membership|
        User.new(membership.uid, session)
      end
    end
    
    ##
    # Get a list of Membership instances associated with this Group.  First call retrieves the Membership instances via a Facebook
    # API call.  Subsequent calls are retrieved from in-memory cache.
    def memberships
      @memberships ||= session.post('facebook.groups.getMembers', :gid => gid).map do |hash|
        Membership.from_hash(hash) do |membership|
          membership.gid = gid
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 8 rubygems

Version Path
fs-facebooker-1.0.37 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.30 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.31 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.32 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.36 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.37 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.38 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.39 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.40 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.41 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.42 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.43 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.44 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.45 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.46 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.47 lib/facebooker/models/group.rb
mmangino-facebooker-1.0.48 lib/facebooker/models/group.rb
mwilliams-facebooker-1.0.40 lib/facebooker/models/group.rb
pomartel-facebooker-1.0.45 lib/facebooker/models/group.rb
pomartel-facebooker-1.0.47 lib/facebooker/models/group.rb