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



122
123
124
125
126
127
128
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 122

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)


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

def collection?
  true
end

#exist?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 114

def exist?
  @address_book != nil
end

#find_children(ids) ⇒ Object

{ href: uid }



131
132
133
134
135
136
137
# File 'lib/dav4rack_ext/carddav/resources/addressbook_resource.rb', line 131

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



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

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