hey_listen 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a537e70d3718d989a20b2658a545f031a9b5a6f
4
- data.tar.gz: 93f78de8e5f1e2628c8f005df98630916d07a607
3
+ metadata.gz: 30e654c58c8e742bfd71a7014c414377dc3507d8
4
+ data.tar.gz: 778843f600bbe041f423e59d4617c5963a0a47d1
5
5
  SHA512:
6
- metadata.gz: 3c54b58059ddcc86f5e2ee17cd65ca00e9d69381ac314aeda78304bc48f920453c0197ffca23a6ff25ada7d6f7006736ae391965dd435eb47705d0d1003dc63f
7
- data.tar.gz: f4190101fd9495aab6c292a8b0eea635e5f9c8a4be72898ba1db0808e9ccfdd589be9372506dee98cd0febe87f3e818dc336ea1d90844432b2f69a82b05cf625
6
+ metadata.gz: 592f623274ef3340b5d86102749b0cf88a42f7f4e431ac806cb85b51e463af986df3ed7155a46719ab18a7675b4f0cc9f7b5376a0a989c65643271645091f714
7
+ data.tar.gz: 48abf1b30b339dcace2b05fbb163c51e68686a74f8bf66e624983e6fa3625826ea207667a02991afe851068ca211d9ce2184e0e59c125cb8b1e6474dd2304e01
@@ -0,0 +1,43 @@
1
+ module HeyListen
2
+ class Notification < ActiveRecord::Base
3
+ belongs_to :user
4
+ belongs_to :notifiable, polymorphic: true
5
+
6
+ scope :unread, -> { where(read: false) }
7
+
8
+ def notification
9
+ "Notifications::#{label}".constantize.new(notifiable, user)
10
+ end
11
+ delegate :accepted?, :requires_action?, :image, :text, :content, to: :notification
12
+
13
+ def date
14
+ -> (d) {
15
+ [d.year, d.month.pred, d.day]
16
+ }.call(created_at)
17
+ end
18
+
19
+ def as_json(options = {})
20
+ {
21
+ id: id,
22
+ image: image,
23
+ text: text,
24
+ content: content,
25
+ accepted: accepted?,
26
+ requires_action: requires_action?,
27
+ actions: actions,
28
+ read: read,
29
+ date: date
30
+ }
31
+ rescue Exception => e
32
+ {
33
+ text: "Notification ##{id} couldn't be displayed correctly.",
34
+ content: [{
35
+ type: 'text',
36
+ text: "Notification ##{id} couldn't be displayed correctly."
37
+ }],
38
+ date: date,
39
+ error: e.message
40
+ }
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails/generators/base'
2
+
3
+ module HeyListen
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc 'Creates Hey! Listen! necessary migrations.'
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module HeyListen
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hey_listen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Escobedo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,9 +52,10 @@ files:
52
52
  - app/assets/stylesheets/hey_listen/application.css
53
53
  - app/controllers/hey_listen/application_controller.rb
54
54
  - app/helpers/hey_listen/application_helper.rb
55
- - app/models/notification.rb
55
+ - app/models/hey_listen/notification.rb
56
56
  - app/views/layouts/hey_listen/application.html.erb
57
57
  - config/routes.rb
58
+ - lib/generators/hey_listen/install.rb
58
59
  - lib/hey_listen.rb
59
60
  - lib/hey_listen/engine.rb
60
61
  - lib/hey_listen/version.rb
@@ -1,2 +0,0 @@
1
- class Notification < ActiveRecord::Base
2
- end