Class: Roca::Group
- Inherits:
-
Object
- Object
- Roca::Group
- Extended by:
- ConnectorHelper::ClassMethods
- Includes:
- ConnectorHelper
- Defined in:
- lib/roca/group.rb
Instance Attribute Summary collapse
-
#group_id ⇒ Object
readonly
Returns the value of attribute group_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .build_from_hash(attributes = {}) ⇒ Object
- .build_from_xml(xml_description) ⇒ Object
- .create(attributes = {}) ⇒ Object
- .find(group_id) ⇒ Object
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(attributes = {}) ⇒ Group
constructor
A new instance of Group.
Methods included from ConnectorHelper::ClassMethods
Methods included from ConnectorHelper
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_id ⇒ Object (readonly)
Returns the value of attribute group_id.
6 7 8 |
# File 'lib/roca/group.rb', line 6 def group_id @group_id end |
#name ⇒ Object (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
#delete ⇒ Object
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 |