active_domain 0.5.2 → 0.5.3

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: dba24b25451d6eff8aeeadc8c90edee4ce6c8132
4
- data.tar.gz: b0a247ad9a6bd988f8d43baca1f7d8eb3d4e37c0
3
+ metadata.gz: 4300944cb388d1c759829594b8e8aadca5808f40
4
+ data.tar.gz: 0a879f57bfee653fc04f2c7d4f5153fececf4f9c
5
5
  SHA512:
6
- metadata.gz: 17d75cd474e7768d0a5a68c07ff9488ce47266279887e720f6694305749433ea519900b53d54a8483ebf3f2d355e48d636c1378fb14618e677b5b8dc1b461fed
7
- data.tar.gz: c4be45e3ca5b05463deb3e79a065f3966bf988be03280ba7f5e160184bac54a7a572afa4e515495a7260e05f6f2913a18e9b82e3dc5c3c1a31c4eddbfc034ef7
6
+ metadata.gz: ef42ad447b93a6e3402fecd9cb5488f0d4d60ca59cf75a242fd1ff87e3c0d33cef46d766c01fcae20fa5b074422997291a04c37690e0667422bdcd6c3f0fec57
7
+ data.tar.gz: 43f8be9d7dc0f2048e4cd93ed4f42471a9a4ca28bfc7bed6a98877a41aeeb6d7adc99491fe8f476d1c3469f4f6a325624db599a4aac870ba349adec3b9f5ba5b
@@ -1,20 +1,20 @@
1
- Copyright (c) 2013 Andreas Reischuck
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ Copyright (c) 2013 Andreas Reischuck
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Active Domain
2
-
3
- A framework that allows to write a domain server, that processes commands and creates events.
4
-
5
- You should have exactly one domain server for your Rails Disco applications.
6
- The domain runs in a domain specific database environment. This helps to make sure no other process interferes with the domain.
7
-
8
- Have a look at the [rails-disco](https://github.com/hicknhack-software/rails-disco/wiki) documentation on Github for more details.
1
+ # Active Domain
2
+
3
+ A framework that allows to write a domain server, that processes commands and creates events.
4
+
5
+ You should have exactly one domain server for your Rails Disco applications.
6
+ The domain runs in a domain specific database environment. This helps to make sure no other process interferes with the domain.
7
+
8
+ Have a look at the [rails-disco](https://github.com/hicknhack-software/rails-disco/wiki) documentation on Github for more details.
@@ -1,10 +1,10 @@
1
- module ActiveDomain
2
- class Event < ActiveEvent::Event
3
- self.table_name = 'domain_events'
4
-
5
- # allow write inside the domain
6
- def readonly?
7
- @readonly
8
- end
9
- end
10
- end
1
+ module ActiveDomain
2
+ class Event < ActiveEvent::Event
3
+ self.table_name = 'domain_events'
4
+
5
+ # allow write inside the domain
6
+ def readonly?
7
+ @readonly
8
+ end
9
+ end
10
+ end
@@ -1,17 +1,16 @@
1
- module ActiveDomain
2
- class EventRepository
3
-
4
- def self.ordered
5
- ActiveDomain::Event.order(:id)
6
- end
7
-
8
- def self.after_id(id)
9
- ordered.where ActiveDomain::Event.arel_table['id'].gt(id)
10
- end
11
-
12
- def self.store(event)
13
- stored_event = ActiveDomain::Event.create!(event: event.class.name, data: event.to_hash)
14
- event.add_store_infos id: stored_event.id, created_at: stored_event.created_at
15
- end
16
- end
17
- end
1
+ module ActiveDomain
2
+ class EventRepository
3
+ def self.ordered
4
+ ActiveDomain::Event.order(:id)
5
+ end
6
+
7
+ def self.after_id(id)
8
+ ordered.where ActiveDomain::Event.arel_table['id'].gt(id)
9
+ end
10
+
11
+ def self.store(event)
12
+ stored_event = ActiveDomain::Event.create!(event: event.class.name, data: event.to_hash)
13
+ event.add_store_infos id: stored_event.id, created_at: stored_event.created_at
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
- module ActiveDomain
2
- class UniqueCommandId < ActiveRecord::Base
3
- self.table_name = 'unique_command_ids'
4
- end
5
- end
1
+ module ActiveDomain
2
+ class UniqueCommandId < ActiveRecord::Base
3
+ self.table_name = 'unique_command_ids'
4
+ end
5
+ end
@@ -1,23 +1,24 @@
1
- module ActiveDomain
2
- class UniqueCommandIdRepository
3
- def self.new_for(command_name)
4
- @@commands[command_name] ||= create_or_get(command_name)
5
- create_new @@commands[command_name]
6
- end
7
-
8
- private
9
- def self.initialize
10
- end
11
-
12
- def self.create_or_get(command_name)
13
- UniqueCommandId.find_or_create_by! command: command_name
14
- end
15
-
16
- def self.create_new(command)
17
- command.update! last_id: command.last_id + 1
18
- command.last_id
19
- end
20
-
21
- @@commands = {}
22
- end
23
- end
1
+ module ActiveDomain
2
+ class UniqueCommandIdRepository
3
+ def self.new_for(command_name)
4
+ @@commands[command_name] ||= create_or_get(command_name)
5
+ create_new @@commands[command_name]
6
+ end
7
+
8
+ private
9
+
10
+ def initialize
11
+ end
12
+
13
+ def self.create_or_get(command_name)
14
+ UniqueCommandId.find_or_create_by! command: command_name
15
+ end
16
+
17
+ def self.create_new(command)
18
+ command.update! last_id: command.last_id + 1
19
+ command.last_id
20
+ end
21
+
22
+ @@commands = {}
23
+ end
24
+ end
@@ -1,9 +1,9 @@
1
- class CreateUniqueCommandIds < ActiveRecord::Migration
2
- def change
3
- create_table :unique_command_ids do |t|
4
- t.string :command
5
- t.integer :last_id, default: 0
6
- end
7
- add_index :unique_command_ids, :command, unique: true
8
- end
9
- end
1
+ class CreateUniqueCommandIds < ActiveRecord::Migration
2
+ def change
3
+ create_table :unique_command_ids do |t|
4
+ t.string :command
5
+ t.integer :last_id, default: 0
6
+ end
7
+ add_index :unique_command_ids, :command, unique: true
8
+ end
9
+ end
@@ -1,19 +1,19 @@
1
- require 'active_event'
2
- require 'active_support/core_ext'
3
- require 'active_domain/version'
4
-
5
- module ActiveDomain
6
- extend ActiveSupport::Autoload
7
-
8
- autoload :Autoload
9
- autoload :CommandProcessor
10
- autoload :CommandRoutes
11
- autoload :Projection
12
- autoload :ProjectionRegistry
13
- autoload :Server
14
-
15
- autoload :Event, (File.expand_path '../../app/models/active_domain/event', __FILE__)
16
- autoload :EventRepository, (File.expand_path '../../app/models/active_domain/event_repository',__FILE__)
17
- autoload :UniqueCommandId, (File.expand_path '../../app/models/active_domain/unique_command_id', __FILE__)
18
- autoload :UniqueCommandIdRepository, (File.expand_path '../../app/models/active_domain/unique_command_id_repository',__FILE__)
19
- end
1
+ require 'active_event'
2
+ require 'active_support/core_ext'
3
+ require 'active_domain/version'
4
+
5
+ module ActiveDomain
6
+ extend ActiveSupport::Autoload
7
+
8
+ autoload :Autoload
9
+ autoload :CommandProcessor
10
+ autoload :CommandRoutes
11
+ autoload :Projection
12
+ autoload :ProjectionRegistry
13
+ autoload :Server
14
+
15
+ autoload :Event, (File.expand_path '../../app/models/active_domain/event', __FILE__)
16
+ autoload :EventRepository, (File.expand_path '../../app/models/active_domain/event_repository', __FILE__)
17
+ autoload :UniqueCommandId, (File.expand_path '../../app/models/active_domain/unique_command_id', __FILE__)
18
+ autoload :UniqueCommandIdRepository, (File.expand_path '../../app/models/active_domain/unique_command_id_repository', __FILE__)
19
+ end
@@ -1,9 +1,11 @@
1
- module ActiveDomain
2
- module Autoload
3
- include ActiveEvent::Support::Autoload
4
- private
5
- def self.dir_names
6
- %W(domain/command_processors domain/validations domain/models domain/projections)
7
- end
8
- end
9
- end
1
+ module ActiveDomain
2
+ module Autoload
3
+ include ActiveEvent::Support::Autoload
4
+
5
+ private
6
+
7
+ def self.dir_names
8
+ %w(domain/command_processors domain/validations domain/models domain/projections)
9
+ end
10
+ end
11
+ end
@@ -1,41 +1,41 @@
1
- require 'drb/drb'
2
-
3
- module ActiveDomain
4
- module CommandProcessor
5
- extend ActiveSupport::Concern
6
- include DRb::DRbUndumped
7
-
8
- module ClassMethods
9
- protected
10
-
11
- def process(clazz, method_name = nil, &block)
12
- method_name ||= "process#{clazz.name.split('::').last}"
13
- define_method(method_name, &block)
14
- CommandRoutes.route clazz, self, method_name
15
- end
16
- end
17
-
18
- protected
19
-
20
- def event(event)
21
- store event
22
- publish event
23
- invoke event
24
- event.store_infos[:id]
25
- end
26
-
27
- private
28
-
29
- def invoke(event)
30
- ProjectionRegistry.invoke event
31
- end
32
-
33
- def store(event)
34
- EventRepository.store event
35
- end
36
-
37
- def publish(event)
38
- ActiveEvent::EventServer.publish event
39
- end
40
- end
41
- end
1
+ require 'drb/drb'
2
+
3
+ module ActiveDomain
4
+ module CommandProcessor
5
+ extend ActiveSupport::Concern
6
+ include DRb::DRbUndumped
7
+
8
+ module ClassMethods
9
+ protected
10
+
11
+ def process(clazz, method_name = nil, &block)
12
+ method_name ||= "process#{clazz.name.split('::').last}"
13
+ define_method(method_name, &block)
14
+ CommandRoutes.route clazz, self, method_name
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ def event(event)
21
+ store event
22
+ publish event
23
+ invoke event
24
+ event.store_infos[:id]
25
+ end
26
+
27
+ private
28
+
29
+ def invoke(event)
30
+ ProjectionRegistry.invoke event
31
+ end
32
+
33
+ def store(event)
34
+ EventRepository.store event
35
+ end
36
+
37
+ def publish(event)
38
+ ActiveEvent::EventServer.publish event
39
+ end
40
+ end
41
+ end
@@ -14,7 +14,7 @@ module ActiveDomain
14
14
  RELOADER.execute_if_updated
15
15
  processor, method = @@routes[command.class]
16
16
  processor_instance(processor).method(method).call(command)
17
- rescue Exception => e
17
+ rescue => e
18
18
  LOGGER.error e.message
19
19
  LOGGER.error e.backtrace.join("\n")
20
20
  raise ActiveEvent::DomainExceptionCapture, ["#{e.class.name}: #{e.message}", e.backtrace].to_json, e.backtrace
@@ -1,10 +1,9 @@
1
- module ActiveDomain
2
- module Projection
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- ProjectionRegistry::register(self)
7
- end
8
-
9
- end
10
- end
1
+ module ActiveDomain
2
+ module Projection
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ ProjectionRegistry.register(self)
7
+ end
8
+ end
9
+ end
@@ -1,48 +1,48 @@
1
- require 'singleton'
2
-
3
- module ActiveDomain
4
- class TooManyArgumentsError < StandardError
5
- end
6
-
7
- class ProjectionRegistry
8
- include Singleton
9
-
10
- def self.register(event_handler)
11
- self.registry << event_handler
12
- end
13
-
14
- def self.invoke(event)
15
- instance.invoke event
16
- end
17
-
18
- def invoke(event)
19
- event_type = event.class.name.to_s
20
- return unless handlers.has_key? event_type
21
- handlers[event_type].each do |handler_method|
22
- handler_method.owner.new.send handler_method.name, event
23
- end
24
- end
25
-
26
- private
27
-
28
- cattr_accessor :registry
29
- attr_accessor :handlers
30
-
31
- def initialize
32
- self.handlers = Hash.new do |hash, key|
33
- hash[key] = []
34
- end
35
- self.class.registry.freeze.each do |handler|
36
- handler.public_instance_methods(false).each do |method_name|
37
- method = handler.instance_method method_name
38
- event_type = (method_name.to_s.split('__')*'/').camelcase
39
- raise TooManyArgumentsError if 1 != method.arity
40
- handlers[event_type] << method
41
- end
42
- end
43
- handlers.freeze
44
- end
45
-
46
- self.registry = []
47
- end
48
- end
1
+ require 'singleton'
2
+
3
+ module ActiveDomain
4
+ class TooManyArgumentsError < StandardError
5
+ end
6
+
7
+ class ProjectionRegistry
8
+ include Singleton
9
+
10
+ def self.register(event_handler)
11
+ registry << event_handler
12
+ end
13
+
14
+ def self.invoke(event)
15
+ instance.invoke event
16
+ end
17
+
18
+ def invoke(event)
19
+ event_type = event.class.name.to_s
20
+ return unless handlers.key? event_type
21
+ handlers[event_type].each do |handler_method|
22
+ handler_method.owner.new.send handler_method.name, event
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ cattr_accessor :registry
29
+ attr_accessor :handlers
30
+
31
+ def initialize
32
+ self.handlers = Hash.new do |hash, key|
33
+ hash[key] = []
34
+ end
35
+ self.class.registry.freeze.each do |handler|
36
+ handler.public_instance_methods(false).each do |method_name|
37
+ method = handler.instance_method method_name
38
+ event_type = (method_name.to_s.split('__') * '/').camelcase
39
+ fail TooManyArgumentsError if 1 != method.arity
40
+ handlers[event_type] << method
41
+ end
42
+ end
43
+ handlers.freeze
44
+ end
45
+
46
+ self.registry = []
47
+ end
48
+ end
@@ -1,82 +1,81 @@
1
- require 'active_record'
2
- require 'drb/drb'
3
-
4
- module ActiveDomain
5
- class Server
6
-
7
- def self.run(options = nil)
8
- self.new(options).run
9
- end
10
-
11
- def initialize(new_options = nil)
12
- self.options = new_options.deep_symbolize_keys! unless new_options.nil?
13
- end
14
-
15
- def run
16
- ActiveRecord::Base.establish_connection options[:domain_database]
17
- ActiveEvent::EventServer.start options
18
- drb_uri = URI::Generic.build(options[:drb_server]).to_s
19
- DRb.start_service(drb_uri, domain, options.fetch(:drb_config, {}))
20
- DRb.thread.join
21
- rescue Interrupt
22
- LOGGER.info 'Catching Interrupt'
23
- rescue Exception => e
24
- LOGGER.error e.message
25
- LOGGER.error e.backtrace.join("\n")
26
- raise e
27
- end
28
-
29
- def env
30
- @env = ENV['DOMAIN_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
31
- end
32
-
33
- def options
34
- @options ||= parse_options(ARGV)
35
- end
36
-
37
- def domain
38
- @domain ||= ActiveDomain::CommandRoutes.new
39
- end
40
-
41
- cattr_accessor :base_path
42
- cattr_accessor :config_file
43
-
44
- def config_file
45
- self.class.config_file || File.expand_path('config/disco.yml', base_path)
46
- end
47
-
48
- private
49
-
50
- attr_writer :options
51
- attr_writer :domain
52
-
53
- def default_options
54
- {
55
- drb_server: {
56
- scheme: 'druby',
57
- hostname: '127.0.0.1',
58
- port: 8787,
59
- },
60
- drb_config: {
61
- verbose: true,
62
- },
63
- domain_database: {
64
- adapter: 'sqlite3',
65
- database: File.expand_path('db/domain.sqlite3', base_path)
66
- },
67
- event_connection: {
68
- scheme: 'amqp',
69
- userinfo: nil,
70
- host: '127.0.0.1',
71
- port: 9797,
72
- },
73
- event_exchange: 'events'
74
- }
75
- end
76
-
77
- def parse_options(args)
78
- options = default_options
79
- options.merge! YAML.load_file(config_file)[env].deep_symbolize_keys! unless config_file.blank?
80
- end
81
- end
82
- end
1
+ require 'active_record'
2
+ require 'drb/drb'
3
+
4
+ module ActiveDomain
5
+ class Server
6
+ def self.run(options = nil)
7
+ new(options).run
8
+ end
9
+
10
+ def initialize(new_options = nil)
11
+ self.options = new_options.deep_symbolize_keys! unless new_options.nil?
12
+ end
13
+
14
+ def run
15
+ ActiveRecord::Base.establish_connection options[:domain_database]
16
+ ActiveEvent::EventServer.start options
17
+ drb_uri = URI::Generic.build(options[:drb_server]).to_s
18
+ DRb.start_service(drb_uri, domain, options.fetch(:drb_config, {}))
19
+ DRb.thread.join
20
+ rescue Interrupt
21
+ LOGGER.info 'Catching Interrupt'
22
+ rescue => e
23
+ LOGGER.error e.message
24
+ LOGGER.error e.backtrace.join("\n")
25
+ raise e
26
+ end
27
+
28
+ def env
29
+ @env = ENV['DOMAIN_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
30
+ end
31
+
32
+ def options
33
+ @options ||= parse_options(ARGV)
34
+ end
35
+
36
+ def domain
37
+ @domain ||= ActiveDomain::CommandRoutes.new
38
+ end
39
+
40
+ cattr_accessor :base_path
41
+ cattr_accessor :config_file
42
+
43
+ def config_file
44
+ self.class.config_file || File.expand_path('config/disco.yml', base_path)
45
+ end
46
+
47
+ private
48
+
49
+ attr_writer :options
50
+ attr_writer :domain
51
+
52
+ def default_options
53
+ {
54
+ drb_server: {
55
+ scheme: 'druby',
56
+ hostname: '127.0.0.1',
57
+ port: 8787,
58
+ },
59
+ drb_config: {
60
+ verbose: true,
61
+ },
62
+ domain_database: {
63
+ adapter: 'sqlite3',
64
+ database: File.expand_path('db/domain.sqlite3', base_path),
65
+ },
66
+ event_connection: {
67
+ scheme: 'amqp',
68
+ userinfo: nil,
69
+ host: '127.0.0.1',
70
+ port: 9797,
71
+ },
72
+ event_exchange: 'events',
73
+ }
74
+ end
75
+
76
+ def parse_options(_args)
77
+ options = default_options
78
+ options.merge! YAML.load_file(config_file)[env].deep_symbolize_keys! unless config_file.blank?
79
+ end
80
+ end
81
+ end
@@ -1,7 +1,7 @@
1
1
  module ActiveDomain
2
2
  # Returns the version of the currently loaded ActiveDomain as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new '0.5.2'
4
+ Gem::Version.new '0.5.3'
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
@@ -1,30 +1,30 @@
1
- require_relative '../spec_helper'
2
-
3
- describe ActiveDomain::CommandProcessor do
4
- class TestDummy
5
- include ActiveEvent::EventType
6
- end
7
- class TestDummyProcessor
8
- include ActiveDomain::CommandProcessor
9
-
10
- process TestDummy do |cmd|
11
- event cmd
12
- end
13
- end
14
-
15
- describe 'class helper' do
16
- it 'define event process' do
17
- TestDummyProcessor.instance_method(:processTestDummy).should be
18
- end
19
- end
20
-
21
- describe 'instance' do
22
- it 'allows event method' do
23
- magic_number = TestDummy.new
24
- expect(ActiveDomain::ProjectionRegistry).to receive(:invoke).with(magic_number)
25
- expect(ActiveDomain::EventRepository).to receive(:store).with(magic_number)
26
- expect(ActiveEvent::EventServer).to receive(:publish).with(magic_number)
27
- TestDummyProcessor.new.processTestDummy magic_number
28
- end
29
- end
30
- end
1
+ require_relative '../spec_helper'
2
+
3
+ describe ActiveDomain::CommandProcessor do
4
+ class TestDummy
5
+ include ActiveEvent::EventType
6
+ end
7
+ class TestDummyProcessor
8
+ include ActiveDomain::CommandProcessor
9
+
10
+ process TestDummy do |cmd|
11
+ event cmd
12
+ end
13
+ end
14
+
15
+ describe 'class helper' do
16
+ it 'define event process' do
17
+ expect(TestDummyProcessor.instance_method(:processTestDummy)).to be
18
+ end
19
+ end
20
+
21
+ describe 'instance' do
22
+ it 'allows event method' do
23
+ magic_number = TestDummy.new
24
+ expect(ActiveDomain::ProjectionRegistry).to receive(:invoke).with(magic_number)
25
+ expect(ActiveDomain::EventRepository).to receive(:store).with(magic_number)
26
+ expect(ActiveEvent::EventServer).to receive(:publish).with(magic_number)
27
+ TestDummyProcessor.new.processTestDummy magic_number
28
+ end
29
+ end
30
+ end
@@ -1,25 +1,26 @@
1
- require_relative '../spec_helper'
2
-
3
- describe ActiveDomain::ProjectionRegistry do
4
- class TestEvent
5
- end
6
- class TestProjection
7
- def test_event(event)
8
- end
9
- def dummy_event(event)
10
- end
11
- end
12
- before :all do
13
- ActiveDomain::ProjectionRegistry.register(TestProjection)
14
- end
15
-
16
- it 'initializes' do
17
- ActiveDomain::ProjectionRegistry.instance.should be
18
- end
19
-
20
- it 'invokes event handlers' do
21
- event = TestEvent.new
22
- expect_any_instance_of(TestProjection).to receive(:test_event).with(event)
23
- ActiveDomain::ProjectionRegistry.invoke(event)
24
- end
25
- end
1
+ require_relative '../spec_helper'
2
+
3
+ describe ActiveDomain::ProjectionRegistry do
4
+ class TestEvent
5
+ end
6
+ class TestProjection
7
+ def test_event(_event)
8
+ end
9
+
10
+ def dummy_event(_event)
11
+ end
12
+ end
13
+ before :all do
14
+ ActiveDomain::ProjectionRegistry.register(TestProjection)
15
+ end
16
+
17
+ it 'initializes' do
18
+ expect(ActiveDomain::ProjectionRegistry.instance).to be
19
+ end
20
+
21
+ it 'invokes event handlers' do
22
+ event = TestEvent.new
23
+ expect_any_instance_of(TestProjection).to receive(:test_event).with(event)
24
+ ActiveDomain::ProjectionRegistry.invoke(event)
25
+ end
26
+ end
@@ -1,12 +1,12 @@
1
- require_relative '../spec_helper'
2
-
3
- describe ActiveDomain::Projection do
4
- it 'should register automatically' do
5
- expect(ActiveDomain::ProjectionRegistry).to receive(:register) do |arg|
6
- arg.name.to_sym.should eq :TestProjection
7
- end
8
- class TestProjection
9
- include ActiveDomain::Projection
10
- end
11
- end
12
- end
1
+ require_relative '../spec_helper'
2
+
3
+ describe ActiveDomain::Projection do
4
+ it 'should register automatically' do
5
+ expect(ActiveDomain::ProjectionRegistry).to receive(:register) do |arg|
6
+ expect(arg.name.to_sym).to eq(:TestProjection)
7
+ end
8
+ class TestProjection
9
+ include ActiveDomain::Projection
10
+ end
11
+ end
12
+ end
@@ -3,4 +3,4 @@ Coveralls.wear!
3
3
  require 'factory_girl'
4
4
 
5
5
  require 'active_domain'
6
- LOGGER ||= Logger.new(STDOUT)
6
+ LOGGER ||= Logger.new(STDOUT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_domain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - HicknHack Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_event
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.2
19
+ version: 0.5.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.2
26
+ version: 0.5.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement