Sha256: 547acfc5a9581022b8e10a7e1667e758de3ae7eefa830e0d82d51afc622c8f9d
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require "rubygems" require "activesupport" module NinjaDecorators VERSION = '0.0.2' def self.included(base) base.extend ClassMethods end module ClassMethods @@delayed_alias_method_chains = {} def method_added(meth) if @@delayed_alias_method_chains[meth.to_s] chains_arr = @@delayed_alias_method_chains.delete(meth.to_s) chains_arr.each do |chain| self.send(:alias_method_chain, meth, chain) end end end def around_filter(around_method, function_names) function_names.each do |func| define_method("#{func}_with_around_filter_wrapper") do |*args| send(around_method, *args) do |*ar_args| send "#{func}_without_around_filter_wrapper", *ar_args end end if self.instance_methods.include?(func.to_s) alias_method_chain func, :around_filter_wrapper else @@delayed_alias_method_chains[func.to_s] ||= [] @@delayed_alias_method_chains[func.to_s] << :around_filter_wrapper end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
haruska-ninja-decorators-0.0.2 | lib/ninja_decorators.rb |