adalog 0.4.0 → 0.4.1

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: c15c023b9348c277ec76330788aa48ff50e97009
4
- data.tar.gz: 1a67e84184ec901ae73f58253decf22e0196e8b5
3
+ metadata.gz: 9e726549691167f64945f6d0bd5057b79fb210db
4
+ data.tar.gz: d9df52ddb63df02578a5b1eb84d16f60dcc5ceba
5
5
  SHA512:
6
- metadata.gz: c80d618c9f584f39167f2ef97b42ff1f05eddb0c6b8f0dab7664d21bd8183e05bdb471baeff58627db214f48e38e3a94c81b12eea0f15c3e664d2c6e15677e38
7
- data.tar.gz: 583ba7212ab7caf2fda0bd7772bbee8af0f7a9b7f59c9ea31c21305593fab93e5f46585e34dd3df75ff9b11fd1b30fa65510d2b3fe567ba78c96af800829c573
6
+ metadata.gz: 1ade73f1d7180ae64863936d8bb28796132170a1d3331c3d7a651ebb5a033ec91df1bc759a06644a380c70f25f9d54b3767801cb86b6f249043cfdcd88a7574f
7
+ data.tar.gz: 5315dcf3c987dd18f6c5a9b5adca744b7ce53bde65ba85b237b94f80e54eaa45530efa95122730751f756da614e8e2d1337e8c92325a31ad3d5e0c472ed61f31
data/README.md CHANGED
@@ -103,11 +103,12 @@ And now if, in the course of building out your application, you can make an adap
103
103
 
104
104
  ## Included Adapters
105
105
 
106
- Much like how useful repositories come built-in, there are also basic adapters included in the project. Presently the only included adapter that saves you from writing your own, is `SimpleLoggingAdapter`, which uses `method_missing` to write entries for every method call made on it. For example:
106
+ Much like how useful repositories come built-in, there are also basic adapters included in the project. Presently the only included adapter that saves you from writing your own, is `SimpleLoggingAdapter`, which is a factory for new logging adapter classes. These classes use `method_missing` to write entries for every method call made on it. For example:
107
107
 
108
108
  ```ruby
109
109
  # After configuring Adalog
110
- adapter = Adalog::SimpleLoggingAdapter.new("StubMoosendAdapter", Adalog.repo)
110
+ klass = Adalog::SimpleLoggingAdapter.new("StubMoosendAdapter", Adalog.repo)
111
+ adapter = klass.new("any", "args", "you", "want", "they're", "ignored!")
111
112
  adapter.unsubscribe_email('baz@example.com')
112
113
  ```
113
114
 
@@ -1,20 +1,36 @@
1
1
  module Adalog
2
- class SimpleLoggingAdapter
2
+ module SimpleLoggingAdapter
3
3
 
4
- attr_reader :service_name, :repo
5
-
6
- def initialize(service_name, repo)
7
- @service_name = service_name
8
- @repo = repo
4
+ def self.new(service_name, repo)
5
+ new_logger_class = Class.new(self::Base)
6
+ new_logger_class.instance_variable_set(:@service_name, service_name)
7
+ new_logger_class.instance_variable_set(:@repo, repo)
8
+ new_logger_class
9
9
  end
10
10
 
11
- ##
12
- # TODO: Record something w.r.t. whether or not a block is given?
13
- def method_missing(msg, *args, &block)
14
- repo.insert(
15
- title: service_name,
16
- message: msg,
17
- details: args)
11
+
12
+ class Base
13
+
14
+ class << self
15
+ def service_name; @service_name ; end
16
+ def repo ; @repo ; end
17
+ end
18
+
19
+ attr_reader :service_name, :repo
20
+
21
+ def initialize(*args, **kwargs, &block)
22
+ @service_name = self.class.service_name
23
+ @repo = self.class.repo
24
+ end
25
+
26
+ ##
27
+ # TODO: Record something w.r.t. whether or not a block is given?
28
+ def method_missing(msg, *args, &block)
29
+ repo.insert(
30
+ title: service_name,
31
+ message: msg,
32
+ details: args)
33
+ end
18
34
  end
19
35
 
20
36
  end
@@ -1,3 +1,3 @@
1
1
  module Adalog
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Kwiatkowski