surroundings 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/surroundings.rb +46 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9bbe794a4be81fe86e264ab4a149d77625ced83c
4
+ data.tar.gz: f62150026200fcbc537b82c4708e6bb6b2fc2585
5
+ SHA512:
6
+ metadata.gz: f7bdcc30bb2ee20ab97f4ce01922d3780d7c1185bde92f1fcf83b6bcc4c5c8236a424f0946d45e70fe974ff54911d26a7fcd4fa96443271d8131834a567a48db
7
+ data.tar.gz: b0dccebc1fd6759f79a8e71dce475d7e47e754e62d62a024c628f487973958181a4dba728770d6e8712801c50039c3664601b8a0221f9631c321f7c36b4a5441
@@ -0,0 +1,46 @@
1
+ module Surroundings
2
+
3
+ def self.included(base)
4
+ base.instance_eval do
5
+
6
+ def surrounding_macros
7
+ @surrounding_macros ||= []
8
+ end
9
+
10
+ def inherited(subclass)
11
+ subclass.instance_variable_set(:@surrounding_macros, self.surrounding_macros.dup)
12
+ super
13
+ end
14
+
15
+ self.extend(Module.new {
16
+ def new(*args, &block)
17
+ instance = super(*args, &block)
18
+ self.surrounding_macros.each { |macro|
19
+ instance.extend macro
20
+ }
21
+ return instance
22
+ end
23
+ })
24
+
25
+ def before(method, *args, &block)
26
+ self.surrounding_macros << Module.new do
27
+ define_method method do |*args|
28
+ self.instance_exec(*args, &block)
29
+ super(*args)
30
+ end
31
+ end
32
+ end
33
+
34
+ def after(method, *args, &block)
35
+ self.surrounding_macros << Module.new do
36
+ define_method method do |*args|
37
+ result = super(*args)
38
+ self.instance_exec(*args, &block)
39
+ result
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: surroundings
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Jaeger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Surrounding method calls.
14
+ email: cjaeger@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/surroundings.rb
20
+ homepage: https://github.com/caJaeger/surroundings
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.6
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Surrounding methods
44
+ test_files: []