Class: Notificon::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/notificon/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Notification

Returns a new instance of Notification.



9
10
11
# File 'lib/notificon/notification.rb', line 9

def initialize(attrs={})
  attrs.each_pair do |k,v| send("#{k}=", v) end
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def action
  @action
end

#actorObject

Returns the value of attribute actor.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def actor
  @actor
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def id
  @id
end

#item_idObject

Returns the value of attribute item_id.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def item_id
  @item_id
end

#item_textObject

Returns the value of attribute item_text.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def item_text
  @item_text
end

#item_urlObject

Returns the value of attribute item_url.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def item_url
  @item_url
end

#occured_atObject

Returns the value of attribute occured_at.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def occured_at
  @occured_at
end

#read_atObject

Returns the value of attribute read_at.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def read_at
  @read_at
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/notificon/notification.rb', line 7

def username
  @username
end

Instance Method Details

#_id=(value) ⇒ Object

provided to enable simple creation from mongo hash objects



14
15
16
# File 'lib/notificon/notification.rb', line 14

def _id=(value)
  @id = value.to_s
end

#read?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/notificon/notification.rb', line 18

def read?
  !read_at.nil?
end

#urlObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/notificon/notification.rb', line 22

def url
  uri = Addressable::URI.parse(item_url)
  params = {Notificon.notification_id_param => id}
  if item_id
    params[Notificon.notification_item_id_param] = item_id 
    params[Notificon.notification_username_param] = username 
  end
  uri.query_values = (uri.query_values || {}).merge(params)
  uri.to_s
end