notifly 0.1.2 → 0.2.0
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 +4 -4
- data/README.md +1 -0
- data/app/controllers/notifly/notifications_controller.rb +1 -1
- data/app/models/notifly/notification.rb +5 -7
- data/db/migrate/20141212122918_add_kind_to_notifly_notification.rb +5 -0
- data/lib/notifly/models/flyable.rb +10 -4
- data/lib/notifly/models/options/fly.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 939b12ea220c250f5b9e543f70c97f344fc0e973
|
4
|
+
data.tar.gz: 6c827c9a14c21d476ddb6bad7b17a22f29e21fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275d3eb8008e16314a5bb02fea4094dea61c905b750d42a2200a1a3d16aa84319943abb33ad76bb266da07f85bd7eb069588cf11d26cae85f6f12b9c1554df5e
|
7
|
+
data.tar.gz: 262dd1bc12350d735cb64f35322fbcb44fb9aa96666ac5063d492caf16d9b3f69f7f95c5636b6227de190e64b29a2be34d2fbc95dcb48bf092d0a62356ddfe80
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ In actual version, notifications are composed by:
|
|
16
16
|
- Read: flag that records if the receiver read the notification
|
17
17
|
- Seen: flag that records if the receiver seen the notification
|
18
18
|
- If and Unless: used to create notifications conditionally
|
19
|
+
- type: helper
|
19
20
|
|
20
21
|
|
21
22
|
# Install
|
@@ -4,7 +4,7 @@ module Notifly
|
|
4
4
|
belongs_to :sender, polymorphic: true
|
5
5
|
belongs_to :receiver, polymorphic: true
|
6
6
|
|
7
|
-
before_validation :convert_data, :
|
7
|
+
before_validation :convert_data, :set_defaults
|
8
8
|
|
9
9
|
scope :all_from, -> (receiver) { where(receiver: receiver) }
|
10
10
|
scope :unseen, -> { where(seen: false) }
|
@@ -30,7 +30,7 @@ module Notifly
|
|
30
30
|
where(created_at: (notifications.first.created_at..notifications.last.created_at))
|
31
31
|
end
|
32
32
|
|
33
|
-
validates :receiver, :template, :mail, presence: true
|
33
|
+
validates :receiver, :template, :mail, :kind, presence: true
|
34
34
|
|
35
35
|
def data
|
36
36
|
YAML.load(read_attribute(:data))
|
@@ -41,12 +41,10 @@ module Notifly
|
|
41
41
|
self.data = read_attribute(:data).to_json
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def set_defaults
|
45
|
+
self.mail ||= :never
|
46
|
+
self.kind ||= :notification
|
45
47
|
self.template ||= :default
|
46
48
|
end
|
47
|
-
|
48
|
-
def set_mail
|
49
|
-
self.mail ||= :never
|
50
|
-
end
|
51
49
|
end
|
52
50
|
end
|
@@ -101,10 +101,12 @@ module Notifly
|
|
101
101
|
end
|
102
102
|
rescue => e
|
103
103
|
logger.error "Something goes wrong with Notifly, will ignore: #{e}"
|
104
|
+
raise e if not Rails.env.production?
|
104
105
|
end
|
105
106
|
|
106
|
-
def notifly_notifications
|
107
|
-
Notifly::Notification.all_from(self)
|
107
|
+
def notifly_notifications(kind=nil)
|
108
|
+
notifications = Notifly::Notification.all_from(self)
|
109
|
+
kind.present? ? notifications.where(kind: kind) : notifications
|
108
110
|
end
|
109
111
|
|
110
112
|
private
|
@@ -123,12 +125,16 @@ module Notifly
|
|
123
125
|
end
|
124
126
|
|
125
127
|
def _eval_for(key, value)
|
126
|
-
if [:template, :mail].include? key.to_sym
|
128
|
+
if [:template, :mail, :kind].include? key.to_sym
|
127
129
|
value
|
128
130
|
elsif value == :self
|
129
131
|
self
|
130
132
|
else
|
131
|
-
|
133
|
+
if value.is_a? Proc
|
134
|
+
instance_exec &value
|
135
|
+
else
|
136
|
+
send(value)
|
137
|
+
end
|
132
138
|
end
|
133
139
|
end
|
134
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Passalini
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- db/migrate/20141104150224_add_data_to_notification.rb
|
204
204
|
- db/migrate/20141117193436_add_seen_to_notifly_notification.rb
|
205
205
|
- db/migrate/20141125165636_add_mail_to_notifly_notifications.rb
|
206
|
+
- db/migrate/20141212122918_add_kind_to_notifly_notification.rb
|
206
207
|
- lib/generators/notifly/install/install_generator.rb
|
207
208
|
- lib/generators/notifly/install/templates/config/initializers/notifly.rb
|
208
209
|
- lib/generators/notifly/install/utils.rb
|