Class: DAV4Rack::Carddav::AddressbookResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/dav4rack_ext/carddav/resources/addressbook_resource.rb

Constant Summary

Constants inherited from Resource

Resource::CARDAV_NS, Resource::PRIVILEGES

Instance Method Summary collapse

Methods inherited from Resource

#current_user, #get_property, #initialize, #is_self?, #properties, #router_params, #user_agent

Methods included from Helpers::Properties

#define_properties, extended

Constructor Details

This class inherits a constructor from DAV4Rack::Carddav::Resource

Instance Method Details

#childrenObject



116
117
118
119
120
121
122
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 116

def children
  Logger.debug "ABR::children(#{public_path})"
  @address_book.contacts.collect do |c|
    Logger.debug "Trying to create this child (contact): #{c.uid.to_s}"
    child(ContactResource, c, @address_book)
  end
end

#collection?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 112

def collection?
  true
end

#exist?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 108

def exist?
  @address_book != nil
end

#find_children(ids) ⇒ Object

{ href: uid }



125
126
127
128
129
130
131
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 125

def find_children(ids)
  @address_book.find_contacts(ids).each_with_object({}) do |(href, contact), ret|
    if contact
      ret[href] = child(ContactResource, contact)
    end
  end
end

#setupObject



103
104
105
106
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 103

def setup
  super
  @address_book = @options[:_object_] || current_user.current_addressbook()
end