Sha256: c336cffc04235b2d306317da74b35ac1f36678263bb8ac2d2ac0e9b91bed8734
Contents?: true
Size: 1003 Bytes
Versions: 3
Compression:
Stored size: 1003 Bytes
Contents
module Hipbot class ReactionFactory < Struct.new(:reactable) attr_reader :current_description private :reactable, :current_description def build(options_stack, block) options = get_options(options_stack) block ||= options.delete(:block) @current_description = nil Reaction.new(reactable, options, block) end def description(text) @current_description = text end def get_reaction_options(params) options = params.extract_options! get_reaction_method_proc(params) do |block| options[:block] = block end options[:regexps] = params if params.any? options.merge(desc: current_description) end protected def get_reaction_method_proc(params) return unless params.last.kind_of?(Symbol) method_name = params.pop yield ->(*attributes){ plugin.send(method_name, *attributes) } end def get_options(stack) stack.inject{ |all, h| all.merge(h) } || {} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hipbot-1.0.4 | lib/hipbot/reaction_factory.rb |
hipbot-1.0.3 | lib/hipbot/reaction_factory.rb |
hipbot-1.0.0 | lib/hipbot/reaction_factory.rb |