marples 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/marples/active_record.rb +37 -0
- data/lib/marples/version.rb +1 -1
- metadata +8 -7
@@ -0,0 +1,37 @@
|
|
1
|
+
module Marples
|
2
|
+
module ModelActionBroadcast
|
3
|
+
CALLBACKS = [ :save, :create, :update, :destroy, :commit ]
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.class_eval do
|
7
|
+
# Something that response to #subscribe and #publish - although we
|
8
|
+
# only use #publish in this mixin.
|
9
|
+
class_attribute :marples_transport
|
10
|
+
# You *will* need to set this yourself in each application.
|
11
|
+
class_attribute :marples_client_name
|
12
|
+
self.marples_client_name = File.basename(Rails.root)
|
13
|
+
# If you'd like the actions performed by Marples to be logged, set a
|
14
|
+
# logger. By default this uses the NullLogger.
|
15
|
+
class_attribute :marples_logger
|
16
|
+
self.marples_logger = Rails.logger
|
17
|
+
|
18
|
+
CALLBACKS.each do |callback|
|
19
|
+
callback_action = callback.to_s =~ /e$/ ? "#{callback}d" : "#{callback}ed"
|
20
|
+
after_callback = "after_#{callback}"
|
21
|
+
next unless respond_to? after_callback
|
22
|
+
send after_callback do |record|
|
23
|
+
record.class.marples_client.send callback_action, record
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.marples_client
|
28
|
+
@marples_client ||= build_marples_client
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build_marples_client
|
32
|
+
Marples::Client.new(marples_transport, marples_client_name, marples_logger)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/marples/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2011-10-31 00:00:00.000000000Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pethau
|
17
|
-
requirement: &
|
17
|
+
requirement: &70310732945900 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.0.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70310732945900
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: null_logger
|
28
|
-
requirement: &
|
28
|
+
requirement: &70310732945480 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70310732945480
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: activesupport
|
39
|
-
requirement: &
|
39
|
+
requirement: &70310732945020 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70310732945020
|
48
48
|
description: Message destination arbiter
|
49
49
|
email:
|
50
50
|
- craig@barkingiguana.com
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- README.md
|
59
59
|
- Rakefile
|
60
60
|
- lib/marples.rb
|
61
|
+
- lib/marples/active_record.rb
|
61
62
|
- lib/marples/client.rb
|
62
63
|
- lib/marples/null_transport.rb
|
63
64
|
- lib/marples/version.rb
|