Class: Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, collectionName) ⇒ Collection

Creates new collection.

  • Args :

  • Returns : -new instance of collection

  • Raises :

    • nothing ->



27
28
29
30
31
32
# File 'lib/collection.rb', line 27

def initialize(client, collectionName)
  @client = client
  load(collectionName)
rescue  => e
  raise e  
end

Instance Attribute Details

#childCollectionObject (readonly)

descendent collection of the collection



15
16
17
# File 'lib/collection.rb', line 15

def childCollection
  @childCollection
end

#groupObject (readonly)

owner group of the collection



11
12
13
# File 'lib/collection.rb', line 11

def group
  @group
end

#nameObject (readonly)

name of the collection



7
8
9
# File 'lib/collection.rb', line 7

def name
  @name
end

#ownerObject (readonly)

owner of the collection



9
10
11
# File 'lib/collection.rb', line 9

def owner
  @owner
end

#permissionsObject (readonly)

permissions of the collection



13
14
15
# File 'lib/collection.rb', line 13

def permissions
  @permissions
end

Instance Method Details

#[](key) ⇒ Object

Returns instance of collection’s child specified by name.

  • Args :

    • key -> name of the child

  • Returns : -instance of collection’s child (document or collection)

  • Raises :

    • nothing



84
85
86
87
88
89
# File 'lib/collection.rb', line 84

def [](key)
  @documents.each { |d|
    return d if key == d.name 
  }
  return nil
end

#docsObject

Returns string array of all documents in collection

  • Args :

    • none

  • Returns : -array of strings

  • Raises :

    • nothing



69
70
71
72
73
# File 'lib/collection.rb', line 69

def docs    
  ds = []
  @documents.each{ |d| ds.push(d.name)}
  return ds
end

#documentsObject

Yield each document from collection.

  • Args :

    • none

  • Returns : -documents

  • Raises :

    • nothing



56
57
58
# File 'lib/collection.rb', line 56

def documents
  @documents.each { |d| yield d }
end

#to_sObject

Returns string of collection. That inclunde permissions, owner, group and name.

  • Args :

    • none

  • Returns : -string of collection

  • Raises :

    • nothing



43
44
45
# File 'lib/collection.rb', line 43

def to_s()
  return "#{@permissions} #{@owner} #{@group} #{@name}"
end