Module: Kungfuig::ClassMethods
- Includes:
- InstanceMethods
- Defined in:
- lib/kungfuig.rb
Instance Method Summary collapse
- #aspect(meth, after = true) ⇒ Object
- #aspects ⇒ Object
-
#kungfuigure(&block) ⇒ Object
A wrapper for the configuration block.
Methods included from InstanceMethods
#kungfuig, #option, #option!, #option?, #options
Instance Method Details
#aspect(meth, after = true) ⇒ Object
134 135 136 137 138 139 |
# File 'lib/kungfuig.rb', line 134 def aspect meth, after = true fail ArgumentError.new "Aspect must have a codeblock" unless block_given? fail NoMethodError.new "Aspect must be attached to existing method" unless instance_methods.include? meth.to_sym Kungfuig::Prepender.new(self, meth).public_send((after ? :after : :before), &Proc.new).hook! end |
#aspects ⇒ Object
141 142 143 144 145 146 |
# File 'lib/kungfuig.rb', line 141 def aspects ancestors.select { |a| a.name.nil? && a.ancestors.include?(I★I) } .flat_map { |m| m.instance_methods(false) } .group_by { |e| e } .map { |k, v| [k, v.count] }.to_h end |
#kungfuigure(&block) ⇒ Object
A wrapper for the configuration block
130 131 132 |
# File 'lib/kungfuig.rb', line 130 def kungfuigure &block instance_eval(&block) end |