gossiper 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03429984c23e4807f4f54266bbe46994847cbf06
4
- data.tar.gz: a8b43ccbcd2bb8ef653f02ff2b101be9e77dc5eb
3
+ metadata.gz: 1f4ccef0f1edaa89456ae3bb1f0b3a7b45bb3fb4
4
+ data.tar.gz: fa4e83cff30b4b91f75a4a8976dff890cc4d81a7
5
5
  SHA512:
6
- metadata.gz: cf6375937efcb728025156bb3ce812172ead81f2457ff8c2fec08c98eea3146058bbadf0134331145ab8a8ccc0b81114fb1f2329955aee221c0b04a988cf6b5c
7
- data.tar.gz: 4968259de00984aafae126fbd00869482aecc1ec368311e9560ea3693248cda84c36ddba313a455a1f19fde298a1b8fa371f2fb97c22ed9e22b7dc5736f5e5c9
6
+ metadata.gz: b7936bca7c35e763fa8de2ba5dfd207e4ce22d8359980c1e4bd289c8c0fff6ba3f6be6d386b701ba2f1c4b2fc2505a9b13509d924d1068fbb460bed3ad4f91c7
7
+ data.tar.gz: ed5435e238255b2b3e0b53b46c7071bc2fe636880a2c039d7cd16cad8f5678e3ffc58a4ad8ca1e5d62b9caf2f8533e0b5cebda0c05d27cb8e50de9dc43f49f44
@@ -1,5 +1,6 @@
1
1
  module Gossiper
2
2
  class Notification < ActiveRecord::Base
3
3
  include Gossiper::Concerns::Models::Notification
4
+ include Gossiper::Concerns::Models::DynamicAttributes
4
5
  end
5
6
  end
@@ -0,0 +1,5 @@
1
+ class AddDynamicAttributesToGossiperNotifications < ActiveRecord::Migration
2
+ def change
3
+ add_column :gossiper_notifications, :dynamic_attributes, :text
4
+ end
5
+ end
data/lib/gossiper.rb CHANGED
@@ -2,6 +2,7 @@ require "gossiper/engine"
2
2
  require "gossiper/concerns/models/notification"
3
3
  require "gossiper/concerns/models/user_notification"
4
4
  require "gossiper/concerns/models/email_settings"
5
+ require "gossiper/concerns/models/dynamic_attributes"
5
6
  require "gossiper/concerns/decorators/notification"
6
7
  require "gossiper/mailer"
7
8
  require "gossiper/configuration"
@@ -0,0 +1,43 @@
1
+ module Gossiper
2
+ module Concerns
3
+ module Models
4
+ module DynamicAttributes
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ serialize :dynamic_attributes, JSON
9
+ end
10
+
11
+ module ClassMethods
12
+ def dynamic_attributes(*args)
13
+ args.each do |method|
14
+
15
+ # dynamic getters
16
+ define_method method do
17
+ dynamic_attribute_get(method)
18
+ end
19
+
20
+ # dynamic setters
21
+ define_method "#{method}=" do |value|
22
+ dynamic_attribute_set(method, value)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def dynamic_attribute_set(name, value)
29
+ self.dynamic_attributes = dynamic_attributes.merge({ name.to_s => value })
30
+ end
31
+
32
+ def dynamic_attribute_get(name)
33
+ self.dynamic_attributes[name.to_s]
34
+ end
35
+
36
+ def dynamic_attributes
37
+ read_attribute(:dynamic_attributes).presence || {}
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Gossiper
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gossiper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
@@ -203,6 +203,7 @@ files:
203
203
  - app/controllers/gossiper/application_controller.rb
204
204
  - config/routes.rb
205
205
  - config/locales/en.bootstrap.yml
206
+ - db/migrate/20140304160545_add_dynamic_attributes_to_gossiper_notifications.rb
206
207
  - db/migrate/20140304131816_remove_kind_from_gossiper_notifications.rb
207
208
  - db/migrate/20140304111323_add_to_to_gossiper_notifications.rb
208
209
  - db/migrate/20131206162038_create_gossiper_notifications.rb
@@ -223,6 +224,7 @@ files:
223
224
  - lib/gossiper/engine.rb
224
225
  - lib/gossiper/concerns/decorators/notification.rb
225
226
  - lib/gossiper/concerns/models/email_settings.rb
227
+ - lib/gossiper/concerns/models/dynamic_attributes.rb
226
228
  - lib/gossiper/concerns/models/notification.rb
227
229
  - lib/gossiper/concerns/models/user_notification.rb
228
230
  - lib/gossiper/mailer.rb