Sha256: 37159656d931c786ffdf8a9755bf8a7c232aa967f1bbb4bedd51bc269c9f1790

Contents?: true

Size: 1002 Bytes

Versions: 3

Compression:

Stored size: 1002 Bytes

Contents

module GoogleContactsApi
  # Represents a single group.
  class Group < GoogleContactsApi::Result
    include GoogleContactsApi::Contacts

    # Return true if this is a system group.
    def system_group?
      !self["gContact$systemGroup"].nil?
    end

    # Return the contacts in this group and cache them.
    def contacts(params = {})
      # contacts in this group
      @contacts ||= get_contacts({"group" => self.id}.merge(params))
    end

    # Return the contacts in this group, retrieving them again from the server.
    def contacts!(params = {})
      # contacts in this group
      @contacts = nil
      contacts
    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

3 entries across 3 versions & 1 rubygems

Version Path
google_contacts_api-0.6.0 lib/google_contacts_api/group.rb
google_contacts_api-0.5.1 lib/google_contacts_api/group.rb
google_contacts_api-0.5.0 lib/google_contacts_api/group.rb