Class: CalendarToQueue::GoogleCalendarPush
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CalendarToQueue::GoogleCalendarPush
- Defined in:
- app/models/calendar_to_queue/google_calendar_push.rb
Instance Method Summary collapse
- #payload ⇒ Object
- #process ⇒ Object
-
#queue_name ⇒ Object
A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.).
- #token_hash ⇒ Object
Instance Method Details
#payload ⇒ Object
16 17 18 |
# File 'app/models/calendar_to_queue/google_calendar_push.rb', line 16 def payload attributes.slice('channel_id', 'message_number', 'resource_id', 'state', 'resource_uri', 'expiration', 'token') end |
#process ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/models/calendar_to_queue/google_calendar_push.rb', line 3 def process if self.token.blank? log("No Token", :warn) else send_to_queue if queue? save if persist? end unless queue? log("Token: #{self.token}") end end |
#queue_name ⇒ Object
A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The name must not start or end with a period, and it should not have successive periods. The name is case sensitive and must be unique among all attribute names for the message. The name can be up to 256 characters long. The name cannot start with “AWS.” or “Amazon.” (or any variations in casing) because these prefixes are reserved for use by Amazon Web Services.
33 34 35 36 |
# File 'app/models/calendar_to_queue/google_calendar_push.rb', line 33 def queue_name match_data = (token_hash['queue']||'').match(/^((?!(aws|amazon|\.))[a-z,0-9,_,\-,\.]{1,256})$/i) match_data[0] if match_data end |
#token_hash ⇒ Object
48 49 50 |
# File 'app/models/calendar_to_queue/google_calendar_push.rb', line 48 def token_hash @token_hash ||= (token ||'').split('&').map {|x| x.split("=") }.to_h end |