Module: Necromancy::Control
- Included in:
- Necromancy, Alternative, Applicative, Arrow, Category
- Defined in:
- lib/necromancy/control.rb
Defined Under Namespace
Modules: Alternative, Applicative, Arrow, Category
Class Method Summary collapse
Instance Method Summary collapse
-
#[](target, *targets) ⇒ Control
Reveals some methods and Creates some aliases.
- #call(*targets) ⇒ Object deprecated Deprecated.
-
#hiding(name, *names) ⇒ Control
Hides some methods.
-
#new ⇒ Necromancy
Creates a Necromancy object including the Control.
- #using(*targets) ⇒ Object deprecated Deprecated.
Class Method Details
.extended(mod) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/necromancy/control.rb', line 78 def self.extended(mod) return unless mod.name and mod.name.start_with? self.name mthname = mod.name.sub("#{self.name}::", '') define_method mthname do |*args, &block| if args.empty? branch { include mod } else branch { include mod; protected *mod.instance_methods }[*args, &block] end end end |
Instance Method Details
#[](target, *targets) ⇒ Control
Reveals some methods and Creates some aliases.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/necromancy/control.rb', line 50 def [](target, *targets) targets.unshift(target) names = targets.select { |t| t.is_a? Symbol } aliases = targets.select { |t| t.is_a? Hash }.inject(:merge) || {} branch do public *names aliases.each do |org, als| alias_method(als, org) protected org public als end end end |
#call(*targets) ⇒ Object
Deprecated.
20 21 22 23 24 25 26 |
# File 'lib/necromancy/control.rb', line 20 def call(*targets) warn <<EOF Necromancy.Hoge.() deprecated. Use Necromancy.Hoge(). EOF branch { protected *instance_methods }[*targets] end |
#hiding(name, *names) ⇒ Control
Hides some methods.
73 74 75 76 |
# File 'lib/necromancy/control.rb', line 73 def hiding(name, *names) names.unshift(name) branch { protected *names } end |
#new ⇒ Necromancy
Creates a Necromancy object including the Necromancy::Control.
7 8 9 10 |
# File 'lib/necromancy/control.rb', line 7 def new mod = self Class.new(::Necromancy::Necromancy) { include mod }.new end |
#using(*targets) ⇒ Object
Deprecated.
29 30 31 32 33 34 35 |
# File 'lib/necromancy/control.rb', line 29 def using(*targets) warn <<EOF Necromancy.Hoge.using() deprecated. Use Necromancy.Hoge[]. EOF self[*targets] end |