Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class Contact
  2. attr_accessor :auth_token
  3.  
  4. def initialize(contact_hash)
  5. ...
  6. end
  7.  
  8. def edit(...)
  9. auth_token.can! :read, self
  10. end
  11. end
  12.  
  13. token = AuthorizationToken.new(session)
  14. contact = SomeService.get_contact(...)
  15.  
  16. contact.edit(...)
  17. # raise error because auth_token is not set
  18.  
  19. contact.auth_token = token
  20.  
  21. contact.edit(...)
  22.  
  23. class QueryService
  24. def initialize(session)
  25. token = AuthorizationToken(session)
  26. end
  27.  
  28. def get_contact
  29. contact = SomeService.get_contact(...)
  30. contact.token = token
  31. end
  32. end
  33.  
  34. contact = QueryService.new(session).get_contact(...)
  35. contact.edit(...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement