Class: Ahub::Group
- Inherits:
-
Object
- Object
- Ahub::Group
- Extended by:
- APIHelpers
- Includes:
- ClassHelpers
- Defined in:
- lib/ahub/group.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #add(user_id) ⇒ Object
- #add_user(user_id) ⇒ Object
-
#initialize(attrs) ⇒ Group
constructor
A new instance of Group.
Methods included from APIHelpers
admin_headers, base_url, find, find_all, headers, object_id_from_response
Methods included from ClassHelpers
Constructor Details
#initialize(attrs) ⇒ Group
Returns a new instance of Group.
7 8 9 |
# File 'lib/ahub/group.rb', line 7 def initialize(attrs) @name = attrs[:name] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/ahub/group.rb', line 6 def name @name end |
Class Method Details
.find_by_name(group_name) ⇒ Object
15 16 17 18 |
# File 'lib/ahub/group.rb', line 15 def self.find_by_name(group_name) matches = find_all matches.find{|group| group.name.downcase.strip == group_name.downcase.strip} end |
Instance Method Details
#add(user_id) ⇒ Object
11 12 13 |
# File 'lib/ahub/group.rb', line 11 def add(user_id) add_user(user_id) end |
#add_user(user_id) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/ahub/group.rb', line 20 def add_user(user_id) raise Exception("No Group Id") unless id move_url = "#{self.class.base_url}/#{id}/add.json?users=#{user_id}" RestClient.put("#{move_url}", self.class.admin_headers) true rescue => e false end |