entity_events 0.0.7 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ab68e2fdb9ac9abfeed8157a96a1fae6ee1e7e2
4
- data.tar.gz: 938f71e55da57b79d33f00e32d00bcd85d944758
3
+ metadata.gz: a2a340022aabd628b4c9ae1de103603eee4bebef
4
+ data.tar.gz: 317c5585fa1926ae107fd22852ed329bbe23cbed
5
5
  SHA512:
6
- metadata.gz: 7a7c51ba9d3c5853a2636da1205f5f707129ba20dc2bece42e4738efc5da5df40c0baef4f2d728f962e8fb2406e241475d95accf7f3d853bd96d0e4ff2a4ed53
7
- data.tar.gz: 5cee9489c373b368bcadfe17c70cdae62d8f998eaf63bde5af8c49a8a59a6f447f5611c07fe216820bf6f86bbad4ae84e53a165730f4533cd8665fd9795ad904
6
+ metadata.gz: c8b07b484af82dd5fdba3745eb34734793f8433b168a1f919cbcd7c94606a881f6d496d66bc26d77de5e37bf0c26ec777825259e5081561fa525d8bcf8381bb5
7
+ data.tar.gz: 225bf84013440fc6b34e16e430cce34b9f679f47dbe0efb7bd257cee992674b28bc2ca767c75b7d4c1cb63d02c7a711e7a3079c0c4f96138d1e16a3957841ab4
data/README.rdoc CHANGED
@@ -41,7 +41,7 @@ gem 'entity_events'
41
41
  t.string :action
42
42
  t.string :controller
43
43
  t.string :flag
44
- t.text :parameters
44
+ t.string :request_ip
45
45
  t.references :actor, polymorphic: true
46
46
  t.references :target, polymorphic: true
47
47
  t.timestamps
@@ -55,7 +55,7 @@ gem 'entity_events'
55
55
 
56
56
  def entity_events
57
57
  auto_log = true
58
- EntityEvents.record(params, current_user, auto_log)
58
+ EntityEvents.record(request, current_user, auto_log)
59
59
  end
60
60
  ===
61
61
 
@@ -69,7 +69,7 @@ Maybe you don't want to record every single request, and you only want to record
69
69
 
70
70
  def entity_events
71
71
  auto_log = false
72
- EntityEvents.record(params, current_user, auto_log)
72
+ EntityEvents.record(request, current_user, auto_log)
73
73
  end
74
74
  ===
75
75
 
@@ -1,7 +1,7 @@
1
1
  module EntityEvents
2
2
 
3
3
  class Interaction < ActiveRecord::Base
4
- attr_accessible :controller, :action, :parameters, :flag, :actor, :target, :actor_id, :target_id
4
+ attr_accessible :controller, :action, :parameters, :flag, :actor, :target, :actor_id, :target_id, :request_ip
5
5
 
6
6
  belongs_to :actor, polymorphic: true
7
7
  belongs_to :target, polymorphic: true
@@ -10,8 +10,5 @@ module EntityEvents
10
10
  Interaction.create(interaction)
11
11
  end
12
12
 
13
- def params
14
- YAML::load(parameters)
15
- end
16
13
  end
17
14
  end
@@ -1,3 +1,3 @@
1
1
  module EntityEvents
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/entity_events.rb CHANGED
@@ -13,21 +13,20 @@ module EntityEvents
13
13
  end
14
14
 
15
15
  class << self
16
- def record(params, current_user, auto_log = true)
17
- event_finder = EventFinder.find(params[:controller])
18
- entity_event = event_finder.new params, current_user
16
+ def record(request, current_user, auto_log = true)
17
+ event_finder = EventFinder.find(request.filtered_parameters[:controller])
18
+ entity_event = event_finder.new request, current_user
19
19
  entity_event.record if auto_log || entity_event.should_record?
20
20
  end
21
21
  end
22
22
 
23
23
  class EntityEvent
24
- attr_reader :actor, :action ,:target, :params, :current_user, :target_is_user_defined, :actor_is_user_defined
24
+ attr_reader :actor, :action ,:target, :current_user, :target_is_user_defined, :actor_is_user_defined, :request
25
25
 
26
- def initialize(params,current_user)
27
- @params = params
26
+ def initialize(request, current_user)
27
+ @request = request
28
28
  @action = action
29
29
  @current_user = current_user
30
-
31
30
  actor_method = (@action.to_s+'_actor').to_sym
32
31
  @actor = if respond_to?(actor_method)
33
32
  @actor_is_user_defined = true
@@ -47,14 +46,13 @@ module EntityEvents
47
46
  end
48
47
 
49
48
  def record
50
- Interaction.log({
51
- actor: actor,
52
- target: target,
53
- action: action,
54
- controller: controller,
55
- parameters: YAML::dump(params),
56
- flag: flag
57
- })
49
+ Interaction.log({ actor: actor,
50
+ target: target,
51
+ action: action,
52
+ controller: controller,
53
+ flag: flag,
54
+ request_ip: request.remote_ip
55
+ })
58
56
  end
59
57
 
60
58
  def event_class
@@ -75,15 +73,15 @@ module EntityEvents
75
73
 
76
74
  #You can override methods after this line, however it is not nessisary.
77
75
  def controller
78
- params[:controller]
76
+ request.filtered_parameters[:controller]
79
77
  end
80
78
 
81
79
  def action
82
- params[:action]
80
+ request.filtered_parameters[:action]
83
81
  end
84
82
 
85
83
  def flag
86
- params[:flag]
84
+ request.filtered_parameters[:flag]
87
85
  end
88
86
 
89
87
  def default_actor
@@ -91,10 +89,11 @@ module EntityEvents
91
89
  end
92
90
 
93
91
  def default_target
94
- id = params["#{params[:controller].to_s.singularize}_id"] || params[:id]
95
- params[:controller].classify.split(':').last.constantize.find id if id
92
+ id = request.filtered_parameters["#{request.filtered_parameters[:controller].to_s.singularize}_id"] || request.filtered_parameters[:id]
93
+ request.filtered_parameters[:controller].classify.split(':').last.constantize.find id if id
96
94
  end
97
95
 
96
+
98
97
  end
99
98
 
100
99
  end
File without changes
@@ -0,0 +1,3 @@
1
+ Connecting to database specified by database.yml
2
+  (0.4ms) begin transaction
3
+  (0.0ms) rollback transaction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Dean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -81,7 +81,9 @@ files:
81
81
  - test/dummy/db/development.sqlite3
82
82
  - test/dummy/db/migrate/20141124235638_create_interaction.rb
83
83
  - test/dummy/db/schema.rb
84
+ - test/dummy/db/test.sqlite3
84
85
  - test/dummy/log/development.log
86
+ - test/dummy/log/test.log
85
87
  - test/dummy/public/404.html
86
88
  - test/dummy/public/422.html
87
89
  - test/dummy/public/500.html
@@ -138,7 +140,9 @@ test_files:
138
140
  - test/dummy/db/development.sqlite3
139
141
  - test/dummy/db/migrate/20141124235638_create_interaction.rb
140
142
  - test/dummy/db/schema.rb
143
+ - test/dummy/db/test.sqlite3
141
144
  - test/dummy/log/development.log
145
+ - test/dummy/log/test.log
142
146
  - test/dummy/public/404.html
143
147
  - test/dummy/public/422.html
144
148
  - test/dummy/public/500.html