Class: Userlist::Push::Relationship
- Includes:
- Operations::Create, Operations::Delete
- Defined in:
- lib/userlist/push/relationship.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(payload = {}, config = Userlist.config) ⇒ Relationship
constructor
A new instance of Relationship.
- #push? ⇒ Boolean
- #url ⇒ Object
Methods included from Operations::Delete
Methods included from Operations::Create
Methods inherited from Resource
#attribute_names, endpoint, #eql?, from_payload, #hash, #identifier, relationship_names, #relationship_names, relationships, resource_name, #respond_to_missing?, #to_hash, #to_json
Constructor Details
#initialize(payload = {}, config = Userlist.config) ⇒ Relationship
Returns a new instance of Relationship.
10 11 12 13 14 15 16 |
# File 'lib/userlist/push/relationship.rb', line 10 def initialize(payload = {}, config = Userlist.config) raise Userlist::ArgumentError, 'Missing required payload' unless payload raise Userlist::ArgumentError, 'Missing required parameter :user' unless payload[:user] raise Userlist::ArgumentError, 'Missing required parameter :company' unless payload[:company] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Userlist::Push::Resource
Instance Method Details
#push? ⇒ Boolean
25 26 27 |
# File 'lib/userlist/push/relationship.rb', line 25 def push? user&.push? && company&.push? end |
#url ⇒ Object
18 19 20 21 22 23 |
# File 'lib/userlist/push/relationship.rb', line 18 def url raise Userlist::Error, "Cannot generate url for #{self.class.name} without a user" unless user raise Userlist::Error, "Cannot generate url for #{self.class.name} without a company" unless company "#{self.class.endpoint}/#{user.identifier}/#{company.identifier}" end |