Sha256: 8cf4478be45cebbd3d5069f33b1197657443338fe489091e119edd2169e05c38
Contents?: true
Size: 811 Bytes
Versions: 4
Compression:
Stored size: 811 Bytes
Contents
module Nyoibo module Callback def self.callbacks @callbacks ||= {:before => {}, :after => {}} end def self.included(base) base.extend ClassMethod end module ClassMethod [:before, :after].each do |prefix| module_eval <<-EOS, __FILE__, __LINE__ def #{prefix}_upload(path, &block) if ENV["NYOIBO_ENV"] == "production" && Nyoibo::Callback.callbacks[#{prefix}][path] raise "Already defined #{prefix} updated callback." end Nyoibo::Callback.callbacks[:#{prefix}][path] = block end EOS end end module Runner def run_callback(prefix, path="/", *args) block = Nyoibo::Callback.callbacks[prefix][path] block.call(*args) if block end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
nyoibo-0.0.3.3 | lib/nyoibo/callback.rb |
nyoibo-0.0.3.2 | lib/nyoibo/callback.rb |
nyoibo-0.0.3.1 | lib/nyoibo/callback.rb |
nyoibo-0.0.3 | lib/nyoibo/callback.rb |