Sha256: abc181be16f96e28b882e5ff773142564b28ff494a1c427fb20d265e0b536e6c

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

module Woopy
  class Account < Resource
    def employ(user, role = nil)
      Employment.create(account_id: self.id, user_id: user.id, role: role)
    end

    def unemploy(employment)
      employment.destroy
    end

    def make_owner(user, role = nil)
      Ownership.create(account_id: self.id, user_id: user.id, role: role)
    end

    def employments
      Employment.find(:all, params: {account_id: self.id} )
    end

    def find_employment(user)
      employment_json = Account.get("#{self.id}/users/#{user.id}/employment")

      Employment.new(employment_json, true)
    end

    def grant_role(user, roles)
      false unless roles.class == Array
      Account.put("#{self.id}/users/#{user.id}/update_roles", { roles: roles })
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
woopy-0.3.0 lib/woopy/account.rb