Class: Googletastic::AccessRule

Inherits:
Base
  • Object
show all
Defined in:
lib/googletastic/access_rule.rb

Constant Summary

Constants included from Mixins::Namespaces

Mixins::Namespaces::NAMESPACES

Instance Attribute Summary collapse

Attributes inherited from Base

#acl, #attachment_path, #created_at, #etag, #head, #id, #keep_raw, #raw, #response, #synced_with, #updated_at

Attributes included from Mixins::Attributes

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client_class, #initialize, #to_xml

Methods included from Mixins::Pagination

included

Methods included from Mixins::Finders

included

Methods included from Mixins::Parsing

included

Methods included from Mixins::Requesting

included

Methods included from Mixins::Attributes

#attribute_names, #has_attribute?, #inspect

Methods included from Mixins::Namespaces

included

Constructor Details

This class inherits a constructor from Googletastic::Base

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



3
4
5
# File 'lib/googletastic/access_rule.rb', line 3

def agent
  @agent
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/googletastic/access_rule.rb', line 3

def email
  @email
end

#roleObject

Returns the value of attribute role.



3
4
5
# File 'lib/googletastic/access_rule.rb', line 3

def role
  @role
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/googletastic/access_rule.rb', line 3

def title
  @title
end

Class Method Details

.build_url(options) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/googletastic/access_rule.rb', line 7

def build_url(options)
  base = nil
  if options.has_key?(:document_id)
    options[:client] = Googletastic::Document.client
    base = "http://docs.google.com/feeds/acl/private/full/#{options[:document_id]}"
  end
  options[:url] = base
  super(options)
end

.marshall(record) ⇒ Object



35
36
37
# File 'lib/googletastic/access_rule.rb', line 35

def marshall(record)
  
end

.unmarshall(xml) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/googletastic/access_rule.rb', line 17

def unmarshall(xml)
  records = xml.xpath("//atom:entry", ns_tag("atom")).collect do |record|
    title = id = value = nil # reset
    id          = record.xpath("atom:id", ns_tag("atom")).text
    title       = record.xpath("atom:title", ns_tag("atom")).text
    scope       = record.xpath("gAcl:scope", ns_tag("gAcl")).first
    role        = record.xpath("gAcl:role", ns_tag("gAcl")).first["value"].to_s
    Googletastic::AccessRule.new(
      :id => id,
      :title => title,
      :email => scope["value"].to_s,
      :agent => scope["type"].to_s,
      :role => role
    )
  end
  records
end

Instance Method Details

#has_access?(email) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/googletastic/access_rule.rb', line 41

def has_access?(email)
  self.email == email
end