Class: Userlist::Push::Event

Inherits:
Resource show all
Includes:
Operations::Push
Defined in:
lib/userlist/push/event.rb

Instance Attribute Summary

Attributes inherited from Resource

#config, #context, #payload

Instance Method Summary collapse

Methods included from Operations::Push

included

Methods inherited from Resource

association_names, #association_names, associations, #attribute_names, endpoint, #eql?, #for_context, from_payload, #hash, #identifier, resource_name, #respond_to_missing?, #to_hash, #to_json

Constructor Details

#initialize(payload = {}, config = Userlist.config) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
14
15
16
# 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]

  payload[:occurred_at] ||= payload[:occured_at] || Time.now

  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

Returns:

  • (Boolean)


18
19
20
# File 'lib/userlist/push/event.rb', line 18

def push?
  super && (user || company) && (user.nil? || user.push?) && (company.nil? || company.push?)
end