Class: Userlist::Push::Event
- Includes:
- Operations::Create
- Defined in:
- lib/userlist/push/event.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(payload = {}, config = Userlist.config) ⇒ Event
constructor
A new instance of Event.
- #occured_at ⇒ Object
- #push? ⇒ Boolean
Methods included from Operations::Create
Methods inherited from Resource
#attribute_names, endpoint, #eql?, from_payload, #hash, #identifier, relationship_names, #relationship_names, resource_name, #respond_to_missing?, #to_hash, #to_json, #url
Constructor Details
#initialize(payload = {}, config = Userlist.config) ⇒ Event
Returns a new instance of Event.
9 10 11 12 13 14 15 |
# File 'lib/userlist/push/event.rb', line 9 def initialize(payload = {}, config = Userlist.config) raise Userlist::ArgumentError, 'Missing required payload' unless payload raise Userlist::ArgumentError, 'Missing required parameter :name' unless payload[:name] raise Userlist::ArgumentError, 'Missing required parameter :user or :company' unless payload[:user] || 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
#occured_at ⇒ Object
17 18 19 |
# File 'lib/userlist/push/event.rb', line 17 def occured_at payload[:occured_at] || Time.now end |
#push? ⇒ Boolean
21 22 23 |
# File 'lib/userlist/push/event.rb', line 21 def push? (user.nil? || user.push?) && (company.nil? || company.push?) end |