inclusion 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc3f53a5772f78eab0685edaf5bd77eaf5385dc5
4
+ data.tar.gz: 1d1f2b8399630aca283fe1371cf0b994e1e2b95e
5
+ SHA512:
6
+ metadata.gz: ce54154b63eee85a72975a20a131cf229fd4b4c740e2eb66f100447662f69765a56a22951c132a7770fa67c642d16443fd1ad429b61051e6cb94cbbd82b5760d
7
+ data.tar.gz: 92590d1e0b1a84e03649a1f01873884a163ed4b9ff1fd11488b8149e54ea2472e9a1e51ec058d46bccb36b34bfbaca39288f2e5acce48ead17f10ff2ad48a75d
@@ -0,0 +1 @@
1
+ require 'inclusion/inclusion'
@@ -0,0 +1,37 @@
1
+ class Inclusion
2
+ attr_reader :obj
3
+ attr_reader :inclusion_name
4
+
5
+ def initialize(obj, inclusion_name)
6
+ @obj = obj
7
+ @inclusion_name = inclusion_name
8
+ end
9
+
10
+ def self.!(obj, inclusion_name)
11
+ instance = new obj, inclusion_name
12
+ instance.extend_obj
13
+ end
14
+
15
+ def extend_obj
16
+ extension = self.extension
17
+
18
+ if extension.nil?
19
+ return obj
20
+ end
21
+
22
+ obj.extend extension
23
+ end
24
+
25
+ def extension
26
+ return nil unless defined
27
+ obj_const.const_get(inclusion_name, search_ancestors=false)
28
+ end
29
+
30
+ def defined
31
+ obj_const.const_defined?(inclusion_name, search_ancestors=false)
32
+ end
33
+
34
+ def obj_const
35
+ ([Module, Class].include?(obj.class) ? obj : obj.class)
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inclusion
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - The Sans Collective
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Extend an object by a module with its namespace
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/inclusion.rb
20
+ - lib/inclusion/inclusion.rb
21
+ homepage: https://github.com/Sans/inclusion
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.0
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Extend an object by a module with its namespace
45
+ test_files: []