Sha256: 770ea3ba6a5bfedb099925f7b4e2313927aadd7c98faf51de83983eca9f70dd6
Contents?: true
Size: 727 Bytes
Versions: 1
Compression:
Stored size: 727 Bytes
Contents
module Surrounded module Shortcuts private def define_shortcut(name) # if keyword initialize if instance_method(:initialize).parameters.dig(0,0) == :keyreq singleton_class.send(:define_method, name) do |**args| instance = begin self.new(**args) end instance.public_send(name) end else # non-keyword initialize singleton_class.send(:define_method, name) do |*args| instance = begin self.new(*args) end instance.public_send(name) end end end def store_trigger(*names) names.each do |name| define_shortcut(name) end super end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
surrounded-1.1.0 | lib/surrounded/shortcuts.rb |