Sha256: 6ae9927052877466e9ce3021a8bcf98164b33d901e3ca7fb94759430d3832b30

Contents?: true

Size: 928 Bytes

Versions: 14

Compression:

Stored size: 928 Bytes

Contents

module GoogleContactsApi
  class Group < GoogleContactsApi::Result
    include GoogleContactsApi::Contacts
    # Populate from a single entry element in the result response
    # when requesting a set of Contacts

    def system_group?
      !self["gContact$systemGroup"].nil?
    end

    def contacts(params = {})
      # contacts in this group
      @contacts ||= super({"group" => self.id}.merge(params))
    end
    
    def contacts!(params = {})
      # contacts in this group
      @contacts = super({"group" => self.id}.merge(params))
    end
    
    # Returns the array of links, as link is an array for Hashie.
    def links
      self["link"].map { |l| l.href }
    end
    
    def self_link
      _link = self["link"].find { |l| l.rel == "self" }
      _link ? _link.href : nil
    end
    
    def edit_link
      _link = self["link"].find { |l| l.rel == "edit" }
      _link ? _link.href : nil
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
google_contacts_api-0.4.1 lib/google_contacts_api/group.rb
google_contacts_api-0.4.0 lib/google_contacts_api/group.rb
google_contacts_api-0.3.3 lib/google_contacts_api/group.rb
google_contacts_api-0.3.2 lib/google_contacts_api/group.rb
google_contacts_api-0.3.1 lib/google_contacts_api/group.rb
google_contacts_api-0.3.0 lib/google_contacts_api/group.rb
google_contacts_api-0.2.7 lib/google_contacts_api/group.rb
google_contacts_api-0.2.6 lib/google_contacts_api/group.rb
google_contacts_api-0.2.5 lib/google_contacts_api/group.rb
google_contacts_api-0.2.4 lib/google_contacts_api/group.rb
google_contacts_api-0.2.3 lib/google_contacts_api/group.rb
google_contacts_api-0.2.2 lib/google_contacts_api/group.rb
google_contacts_api-0.2.1 lib/google_contacts_api/group.rb
google_contacts_api-0.2.0 lib/google_contacts_api/group.rb