Sha256: 5a40ca387c8d0f169cd04b254c882fc40d683449ebdb8c9928b27333d1e4301c

Contents?: true

Size: 279 Bytes

Versions: 4

Compression:

Stored size: 279 Bytes

Contents

require 'active_support'

class Module
  def define_and_alias(target, feature, &blk)
    aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
    define_method :"#{aliased_target}_with_#{feature}#{punctuation}", &blk
    alias_method_chain target, feature
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
freighthopper-0.1.14 lib/freighthopper/define_and_alias.rb
freighthopper-0.1.13 lib/freighthopper/define_and_alias.rb
freighthopper-0.1.12 lib/freighthopper/define_and_alias.rb
freighthopper-0.1.11 lib/freighthopper/define_and_alias.rb