Sha256: 7f65b6213d50f125d778f241d202289c5dfd1a9ebdd2f13fc9e4c9e1e4ea886f
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module Remarkable module DSL module Callbacks def self.included(base) base.extend ClassMethods end module ClassMethods protected # Class method that accepts a block which is called after initialization. # def after_initialize(symbol=nil, &block) if block_given? @after_initialize_callbacks << block elsif symbol @after_initialize_callbacks << symbol end end # Class method that accepts a block which is called before assertion. # def before_assert(symbol=nil, &block) if block_given? @before_assert_callbacks << block elsif symbol @before_assert_callbacks << symbol end end end def run_after_initialize_callbacks self.class.after_initialize_callbacks.each do |method| if method.is_a?(Proc) instance_eval &method elsif method.is_a?(Symbol) send(method) end end end def run_before_assert_callbacks self.class.before_assert_callbacks.each do |method| if method.is_a?(Proc) instance_eval &method elsif method.is_a?(Symbol) send(method) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remarkable-3.0.0 | lib/remarkable/dsl/callbacks.rb |