Class: Roca::Group

Inherits:
Object
  • Object
show all
Extended by:
ConnectorHelper::ClassMethods
Includes:
ConnectorHelper
Defined in:
lib/roca/group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConnectorHelper::ClassMethods

connector, connector=

Methods included from ConnectorHelper

#connector, #connector=

Constructor Details

#initialize(attributes = {}) ⇒ Group

Returns a new instance of Group.



32
33
34
35
# File 'lib/roca/group.rb', line 32

def initialize(attributes = {})
  @name     = attributes[:name]
  @group_id = attributes[:group_id]
end

Instance Attribute Details

#group_idObject (readonly)

Returns the value of attribute group_id.



6
7
8
# File 'lib/roca/group.rb', line 6

def group_id
  @group_id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/roca/group.rb', line 6

def name
  @name
end

Class Method Details

.build_from_hash(attributes = {}) ⇒ Object



19
20
21
# File 'lib/roca/group.rb', line 19

def self.build_from_hash(attributes = {})
  Group.new(attributes)
end

.build_from_xml(xml_description) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/roca/group.rb', line 23

def self.build_from_xml(xml_description)
  doc = Nokogiri::Slop(xml_description)

  Group.build_from_hash(
    group_id: doc.GROUP.ID.content.to_i,
    name:     doc.GROUP.NAME.content
  )
end

.create(attributes = {}) ⇒ Object



8
9
10
11
12
# File 'lib/roca/group.rb', line 8

def self.create(attributes = {})
  success_flag, group_id, error_code = connector.execute("one.group.allocate", attributes[:name])
  attributes[:group_id] = group_id
  success_flag ? Group.build_from_hash(attributes) : false
end

.find(group_id) ⇒ Object



14
15
16
17
# File 'lib/roca/group.rb', line 14

def self.find(group_id)
  success_flag, xml_object_description, error_code = connector.execute("one.group.info", group_id)
  success_flag ? Group.build_from_xml(xml_object_description) : false
end

Instance Method Details

#deleteObject



37
38
39
40
# File 'lib/roca/group.rb', line 37

def delete
  success_flag, xml_object_description, error_code = connector.execute("one.group.delete", group_id)
  success_flag
end