contextify 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/ChangeLog.md +7 -0
- data/README.md +3 -1
- data/Rakefile +21 -27
- data/contextify.gemspec +6 -81
- data/gemspec.yml +16 -0
- data/lib/contextify/class_methods.rb +4 -21
- data/lib/contextify/contextified_class_methods.rb +45 -0
- data/lib/contextify/version.rb +1 -1
- data/spec/contextify_spec.rb +9 -0
- data/spec/helpers/contexts.rb +1 -0
- data/spec/helpers/contexts/discrete_structures.rb +4 -0
- data/spec/helpers/text_book_context.rb +7 -0
- data/spec/spec_helper.rb +1 -3
- metadata +62 -32
- data/.gitignore +0 -9
- data/.specopts +0 -1
- data/lib/contextify/extensions.rb +0 -1
- data/lib/contextify/extensions/meta.rb +0 -1
- data/lib/contextify/extensions/meta/object.rb +0 -24
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 0.2.0 / 2010-10-27
|
2
|
+
|
3
|
+
* Added {Contextify::ContextifiedClassMethods}.
|
4
|
+
* Fixed a block-variable shadowing bug in
|
5
|
+
{Contextify::ClassMethods#contextify}.
|
6
|
+
* Removed the `metaid.rb` extension.
|
7
|
+
|
1
8
|
### 0.1.6 / 2010-05-23
|
2
9
|
|
3
10
|
* Moved the Contextify YARD handlers into the
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,41 +1,35 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require './lib/contextify/version.rb'
|
4
3
|
|
5
4
|
begin
|
6
|
-
|
7
|
-
|
8
|
-
gem.name = 'contextify'
|
9
|
-
gem.version = Contextify::VERSION
|
10
|
-
gem.license = 'MIT'
|
11
|
-
gem.summary = %Q{Loads Ruby Objects containing methods and procs from Ruby files.}
|
12
|
-
gem.description = %Q{Contextify can load Ruby Objects containing methods and procs from Ruby files without having to use YAML or define classes named like the file.}
|
13
|
-
gem.email = 'postmodern.mod3@gmail.com'
|
14
|
-
gem.homepage = 'http://github.com/postmodern/contextify'
|
15
|
-
gem.authors = ['Postmodern']
|
16
|
-
gem.add_development_dependency 'rspec', '>= 1.3.0'
|
17
|
-
gem.has_rdoc = 'yard'
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
-
end
|
5
|
+
gem 'ore-tasks', '~> 0.1.2'
|
6
|
+
require 'ore/tasks'
|
23
7
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
spec.spec_opts = ['--options', '.specopts']
|
8
|
+
Ore::Tasks.new
|
9
|
+
rescue LoadError => e
|
10
|
+
STDERR.puts e.message
|
11
|
+
STDERR.puts "Run `gem install ore-tasks` to install 'ore/tasks'."
|
29
12
|
end
|
30
13
|
|
31
|
-
|
14
|
+
begin
|
15
|
+
gem 'rspec', '~> 2.0.0'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
|
18
|
+
RSpec::Core::RakeTask.new
|
19
|
+
rescue LoadError => e
|
20
|
+
task :spec do
|
21
|
+
abort "Please run `gem install rspec` to install RSpec."
|
22
|
+
end
|
23
|
+
end
|
32
24
|
task :default => :spec
|
33
25
|
|
34
26
|
begin
|
27
|
+
gem 'yard', '~> 0.6.0'
|
35
28
|
require 'yard'
|
36
|
-
|
37
|
-
|
29
|
+
|
30
|
+
YARD::Rake::YardocTask.new
|
31
|
+
rescue LoadError => e
|
38
32
|
task :yard do
|
39
|
-
abort "
|
33
|
+
abort "Please run `gem install yard` to install YARD."
|
40
34
|
end
|
41
35
|
end
|
data/contextify.gemspec
CHANGED
@@ -1,85 +1,10 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Postmodern"]
|
12
|
-
s.date = %q{2010-05-23}
|
13
|
-
s.description = %q{Contextify can load Ruby Objects containing methods and procs from Ruby files without having to use YAML or define classes named like the file.}
|
14
|
-
s.email = %q{postmodern.mod3@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"ChangeLog.md",
|
17
|
-
"LICENSE.txt",
|
18
|
-
"README.md"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".gitignore",
|
22
|
-
".specopts",
|
23
|
-
".yardopts",
|
24
|
-
"ChangeLog.md",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.md",
|
27
|
-
"Rakefile",
|
28
|
-
"contextify.gemspec",
|
29
|
-
"lib/contextify.rb",
|
30
|
-
"lib/contextify/class_methods.rb",
|
31
|
-
"lib/contextify/contextify.rb",
|
32
|
-
"lib/contextify/exceptions.rb",
|
33
|
-
"lib/contextify/exceptions/context_not_found.rb",
|
34
|
-
"lib/contextify/exceptions/unknown_context.rb",
|
35
|
-
"lib/contextify/extensions.rb",
|
36
|
-
"lib/contextify/extensions/meta.rb",
|
37
|
-
"lib/contextify/extensions/meta/object.rb",
|
38
|
-
"lib/contextify/pending_context.rb",
|
39
|
-
"lib/contextify/version.rb",
|
40
|
-
"lib/contextify/yard.rb",
|
41
|
-
"spec/contextify_spec.rb",
|
42
|
-
"spec/helpers/book_context.rb",
|
43
|
-
"spec/helpers/book_review_context.rb",
|
44
|
-
"spec/helpers/contexts.rb",
|
45
|
-
"spec/helpers/contexts/load_error.rb",
|
46
|
-
"spec/helpers/contexts/neuromancer_review.rb",
|
47
|
-
"spec/helpers/contexts/no_method_error.rb",
|
48
|
-
"spec/helpers/contexts/snow_crash.rb",
|
49
|
-
"spec/helpers/contexts/syntax_error.rb",
|
50
|
-
"spec/spec_helper.rb"
|
51
|
-
]
|
52
|
-
s.has_rdoc = %q{yard}
|
53
|
-
s.homepage = %q{http://github.com/postmodern/contextify}
|
54
|
-
s.licenses = ["MIT"]
|
55
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
56
|
-
s.require_paths = ["lib"]
|
57
|
-
s.rubygems_version = %q{1.3.7}
|
58
|
-
s.summary = %q{Loads Ruby Objects containing methods and procs from Ruby files.}
|
59
|
-
s.test_files = [
|
60
|
-
"spec/spec_helper.rb",
|
61
|
-
"spec/helpers/book_review_context.rb",
|
62
|
-
"spec/helpers/contexts/no_method_error.rb",
|
63
|
-
"spec/helpers/contexts/snow_crash.rb",
|
64
|
-
"spec/helpers/contexts/load_error.rb",
|
65
|
-
"spec/helpers/contexts/syntax_error.rb",
|
66
|
-
"spec/helpers/contexts/neuromancer_review.rb",
|
67
|
-
"spec/helpers/book_context.rb",
|
68
|
-
"spec/helpers/contexts.rb",
|
69
|
-
"spec/contextify_spec.rb"
|
70
|
-
]
|
71
|
-
|
72
|
-
if s.respond_to? :specification_version then
|
73
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
74
|
-
s.specification_version = 3
|
75
|
-
|
76
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
77
|
-
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
78
|
-
else
|
79
|
-
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
80
|
-
end
|
81
|
-
else
|
82
|
-
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
3
|
+
begin
|
4
|
+
Ore::Specification.new do |gemspec|
|
5
|
+
# custom logic here
|
83
6
|
end
|
7
|
+
rescue NameError
|
8
|
+
STDERR.puts "The 'contextify.gemspec' file requires Ore."
|
9
|
+
STDERR.puts "Run `gem install ore` to install Ore."
|
84
10
|
end
|
85
|
-
|
data/gemspec.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
name: contextify
|
2
|
+
summary: Loads Ruby Objects containing methods and procs from Ruby files.
|
3
|
+
description:
|
4
|
+
Contextify can load Ruby Objects containing methods and procs from Ruby
|
5
|
+
files without having to use YAML or define classes named like the file.
|
6
|
+
license: MIT
|
7
|
+
authors: Postmodern
|
8
|
+
email: postmodern.mod3@gmail.com
|
9
|
+
homepage: http://github.com/postmodern/contextify
|
10
|
+
has_yard: true
|
11
|
+
|
12
|
+
development_dependencies:
|
13
|
+
ore: ~> 0.2.0
|
14
|
+
ore-tasks: ~> 0.1.2
|
15
|
+
rspec: ~> 2.0.0
|
16
|
+
yard: ~> 0.6.0
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'contextify/
|
1
|
+
require 'contextify/contextified_class_methods'
|
2
2
|
|
3
3
|
module Contextify
|
4
4
|
module ClassMethods
|
@@ -11,27 +11,10 @@ module Contextify
|
|
11
11
|
def contextify(name)
|
12
12
|
name = name.to_s
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
meta_def(:context_name) { name }
|
17
|
-
|
18
|
-
meta_def(:load_context_block) do |path|
|
19
|
-
Contextify.load_block(name,path)
|
20
|
-
end
|
21
|
-
|
22
|
-
meta_def(:load_context) do |path,*args|
|
23
|
-
pending = Contextify.load_blocks(path)
|
14
|
+
@context_name = name
|
15
|
+
extend ContextifiedClassMethods
|
24
16
|
|
25
|
-
|
26
|
-
Contextify.contexts[name].ancestors.include?(self)
|
27
|
-
end
|
28
|
-
|
29
|
-
if (context && block)
|
30
|
-
obj = Contextify.contexts[name].new(*args)
|
31
|
-
obj.instance_eval(&block)
|
32
|
-
obj
|
33
|
-
end
|
34
|
-
end
|
17
|
+
Contextify.contexts[name] = self
|
35
18
|
|
36
19
|
# define the top-level context wrappers
|
37
20
|
Kernel.module_eval %{
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Contextify
|
2
|
+
module ContextifiedClassMethods
|
3
|
+
# The name of the context
|
4
|
+
attr_reader :context_name
|
5
|
+
|
6
|
+
#
|
7
|
+
# Loads a block defined under the context.
|
8
|
+
#
|
9
|
+
# @param [String] path
|
10
|
+
# The path to load the block from.
|
11
|
+
#
|
12
|
+
# @return [Proc]
|
13
|
+
# The block defined for the context.
|
14
|
+
#
|
15
|
+
def load_context_block(path)
|
16
|
+
Contextify.load_block(@context_name,path)
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Loads a compatible context.
|
21
|
+
#
|
22
|
+
# @param [String] path
|
23
|
+
# The path to load the context from.
|
24
|
+
#
|
25
|
+
# @param [Array] arguments
|
26
|
+
# Additional arguments to use when creating the context.
|
27
|
+
#
|
28
|
+
# @return [Object]
|
29
|
+
# The loaded context.
|
30
|
+
#
|
31
|
+
def load_context(path,*arguments)
|
32
|
+
pending = Contextify.load_blocks(path)
|
33
|
+
|
34
|
+
pending_name, pending_block = pending.find do |name,block|
|
35
|
+
Contextify.contexts[name].ancestors.include?(self)
|
36
|
+
end
|
37
|
+
|
38
|
+
if (pending_name && pending_block)
|
39
|
+
obj = Contextify.contexts[pending_name].new(*arguments)
|
40
|
+
obj.instance_eval(&pending_block)
|
41
|
+
obj
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/contextify/version.rb
CHANGED
data/spec/contextify_spec.rb
CHANGED
@@ -8,6 +8,7 @@ describe Contextify do
|
|
8
8
|
|
9
9
|
before(:all) do
|
10
10
|
@snow_crash_path = context_path(:snow_crash)
|
11
|
+
@discrete_structures_path = context_path(:discrete_structures)
|
11
12
|
@neuromancer_path = context_path(:neuromancer_review)
|
12
13
|
|
13
14
|
@syntax_error_path = context_path(:syntax_error)
|
@@ -17,10 +18,12 @@ describe Contextify do
|
|
17
18
|
|
18
19
|
it "should contain defined contexts" do
|
19
20
|
Contextify.is_context?('book').should == true
|
21
|
+
Contextify.is_context?('text_book').should == true
|
20
22
|
end
|
21
23
|
|
22
24
|
it "should create a class-level context name" do
|
23
25
|
Book.context_name.should == 'book'
|
26
|
+
TextBook.context_name.should == 'text_book'
|
24
27
|
end
|
25
28
|
|
26
29
|
it "should raise UnknownContext when loading unknwon-contexts" do
|
@@ -99,6 +102,12 @@ describe Contextify do
|
|
99
102
|
book.class.should == Book
|
100
103
|
end
|
101
104
|
|
105
|
+
it "should load contexts which inherit from the contextified class" do
|
106
|
+
book = Book.load_context(@discrete_structures_path)
|
107
|
+
book.should_not be_nil
|
108
|
+
book.class.should == TextBook
|
109
|
+
end
|
110
|
+
|
102
111
|
it "should return nil when loading contexts incompatible with the class" do
|
103
112
|
BookReview.load_context(@snow_crash_path).should be_nil
|
104
113
|
end
|
data/spec/helpers/contexts.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contextify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Postmodern
|
@@ -15,25 +14,69 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-10-27 00:00:00 -07:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
21
|
+
name: ore
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
27
|
-
- -
|
26
|
+
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 27
|
30
28
|
segments:
|
31
|
-
- 1
|
32
|
-
- 3
|
33
29
|
- 0
|
34
|
-
|
30
|
+
- 2
|
31
|
+
- 0
|
32
|
+
version: 0.2.0
|
35
33
|
type: :development
|
36
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: ore-tasks
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 1
|
46
|
+
- 2
|
47
|
+
version: 0.1.2
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 0
|
61
|
+
- 0
|
62
|
+
version: 2.0.0
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: yard
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
- 6
|
76
|
+
- 0
|
77
|
+
version: 0.6.0
|
78
|
+
type: :development
|
79
|
+
version_requirements: *id004
|
37
80
|
description: Contextify can load Ruby Objects containing methods and procs from Ruby files without having to use YAML or define classes named like the file.
|
38
81
|
email: postmodern.mod3@gmail.com
|
39
82
|
executables: []
|
@@ -41,27 +84,23 @@ executables: []
|
|
41
84
|
extensions: []
|
42
85
|
|
43
86
|
extra_rdoc_files:
|
44
|
-
- ChangeLog.md
|
45
|
-
- LICENSE.txt
|
46
87
|
- README.md
|
47
88
|
files:
|
48
|
-
- .
|
49
|
-
- .specopts
|
89
|
+
- .rspec
|
50
90
|
- .yardopts
|
51
91
|
- ChangeLog.md
|
52
92
|
- LICENSE.txt
|
53
93
|
- README.md
|
54
94
|
- Rakefile
|
55
95
|
- contextify.gemspec
|
96
|
+
- gemspec.yml
|
56
97
|
- lib/contextify.rb
|
57
98
|
- lib/contextify/class_methods.rb
|
99
|
+
- lib/contextify/contextified_class_methods.rb
|
58
100
|
- lib/contextify/contextify.rb
|
59
101
|
- lib/contextify/exceptions.rb
|
60
102
|
- lib/contextify/exceptions/context_not_found.rb
|
61
103
|
- lib/contextify/exceptions/unknown_context.rb
|
62
|
-
- lib/contextify/extensions.rb
|
63
|
-
- lib/contextify/extensions/meta.rb
|
64
|
-
- lib/contextify/extensions/meta/object.rb
|
65
104
|
- lib/contextify/pending_context.rb
|
66
105
|
- lib/contextify/version.rb
|
67
106
|
- lib/contextify/yard.rb
|
@@ -69,19 +108,21 @@ files:
|
|
69
108
|
- spec/helpers/book_context.rb
|
70
109
|
- spec/helpers/book_review_context.rb
|
71
110
|
- spec/helpers/contexts.rb
|
111
|
+
- spec/helpers/contexts/discrete_structures.rb
|
72
112
|
- spec/helpers/contexts/load_error.rb
|
73
113
|
- spec/helpers/contexts/neuromancer_review.rb
|
74
114
|
- spec/helpers/contexts/no_method_error.rb
|
75
115
|
- spec/helpers/contexts/snow_crash.rb
|
76
116
|
- spec/helpers/contexts/syntax_error.rb
|
117
|
+
- spec/helpers/text_book_context.rb
|
77
118
|
- spec/spec_helper.rb
|
78
119
|
has_rdoc: yard
|
79
120
|
homepage: http://github.com/postmodern/contextify
|
80
121
|
licenses:
|
81
122
|
- MIT
|
82
123
|
post_install_message:
|
83
|
-
rdoc_options:
|
84
|
-
|
124
|
+
rdoc_options: []
|
125
|
+
|
85
126
|
require_paths:
|
86
127
|
- lib
|
87
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -89,7 +130,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
130
|
requirements:
|
90
131
|
- - ">="
|
91
132
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
133
|
segments:
|
94
134
|
- 0
|
95
135
|
version: "0"
|
@@ -98,25 +138,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
138
|
requirements:
|
99
139
|
- - ">="
|
100
140
|
- !ruby/object:Gem::Version
|
101
|
-
hash: 3
|
102
141
|
segments:
|
103
142
|
- 0
|
104
143
|
version: "0"
|
105
144
|
requirements: []
|
106
145
|
|
107
|
-
rubyforge_project:
|
146
|
+
rubyforge_project: contextify
|
108
147
|
rubygems_version: 1.3.7
|
109
148
|
signing_key:
|
110
149
|
specification_version: 3
|
111
150
|
summary: Loads Ruby Objects containing methods and procs from Ruby files.
|
112
151
|
test_files:
|
113
|
-
- spec/spec_helper.rb
|
114
|
-
- spec/helpers/book_review_context.rb
|
115
|
-
- spec/helpers/contexts/no_method_error.rb
|
116
|
-
- spec/helpers/contexts/snow_crash.rb
|
117
|
-
- spec/helpers/contexts/load_error.rb
|
118
|
-
- spec/helpers/contexts/syntax_error.rb
|
119
|
-
- spec/helpers/contexts/neuromancer_review.rb
|
120
|
-
- spec/helpers/book_context.rb
|
121
|
-
- spec/helpers/contexts.rb
|
122
152
|
- spec/contextify_spec.rb
|
data/.gitignore
DELETED
data/.specopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour --format specdoc
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'contextify/extensions/meta'
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'contextify/extensions/meta/object'
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# metaprogramming assistant -- metaid.rb
|
2
|
-
class Object
|
3
|
-
# The hidden singleton lurks behind everyone
|
4
|
-
def metaclass; class << self; self; end; end
|
5
|
-
def meta_eval(&blk); metaclass.instance_eval(&blk); end
|
6
|
-
|
7
|
-
# A class_eval version of meta_eval
|
8
|
-
def metaclass_eval(&blk); metaclass.class_eval(&blk); end
|
9
|
-
|
10
|
-
# A class_def version of meta_def
|
11
|
-
def metaclass_def(name, &blk)
|
12
|
-
metaclass_eval { define_method(name, &blk) }
|
13
|
-
end
|
14
|
-
|
15
|
-
# Adds methods to a metaclass
|
16
|
-
def meta_def(name, &blk)
|
17
|
-
meta_eval { define_method(name, &blk) }
|
18
|
-
end
|
19
|
-
|
20
|
-
# Defines an instance method within a class
|
21
|
-
def class_def(name, &blk)
|
22
|
-
class_eval { define_method(name, &blk) }
|
23
|
-
end
|
24
|
-
end
|