prepend_and_append 0.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/prepend_and_append.rb +29 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e6d15baedbce0e99d2e151dc89d2e3b421e0f37
4
+ data.tar.gz: ca5a078e3121cce68e5e9d7ce774cfb32bffb0d9
5
+ SHA512:
6
+ metadata.gz: 505911e04710d8b26e1f77a7617602673e3491d1726ae2f047c895c3279d992c427fd1e5b43cb264f4a92a75b414d724b3ca3871c437bcf6c78c4164c7bc97c4
7
+ data.tar.gz: 56d9b55b5343163375522f8007bf1f09fef1e4aace9e491e7d44e28a5ef99e1a0e51c5fc73d6732769f4862cb47bae3659022a3767597067c9ebd8d44db14407
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+
3
+ module PrependAndAppend
4
+ def append *methods, &block
5
+ self.caller :append, *methods, &block
6
+ nil
7
+ end
8
+
9
+ def prepend *methods, &block
10
+ self.caller :prepend, *methods, &block
11
+ nil
12
+ end
13
+
14
+ def caller method, *methods, &block
15
+ methods.each do |m|
16
+ m = m.to_sym
17
+
18
+ if defined? m
19
+ singleton_class.send :alias_method, "old_#{m.to_s}".to_sym, m
20
+
21
+ self.define_singleton_method m do
22
+ block.call if block_given? && method == :prepend
23
+ self.send "old_#{m.to_s}".to_sym
24
+ block.call if block_given? && method == :append
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prepend_and_append
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - EvandroLG
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple module to append/prepend block of codes in any method
14
+ email: evandrolgoncalves@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/prepend_and_append.rb
20
+ homepage: https://github.com/EvandroLG/prepend_and_append
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: '0'
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.5.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: PrependAndAppend
44
+ test_files: []