module Datacentred module Model class Role < OpenStruct def initialize(params) params.delete("links") params["created_at"] = Time.parse params["created_at"] params["updated_at"] = Time.parse params["updated_at"] super(params) end def self.all Request::Roles.list.map{|role| new(role) } end def self.find(id) new Request::Roles.show(id) end def self.create(params) new Request::Roles.create(params) end def self.update(id, params) new Request::Roles.update(id, params) end def self.delete(id) Request::Roles.destroy(id) end def self.users(id) Request::Roles.list_users(id).map{|user| new(user) } end def self.add_user(role_id, user_id) Request::Roles.add_user(role_id, user_id) end def self.remove_user(role_id, user_id) Request::Roles.remove_user(role_id, user_id) end end end end